Auto-approve webextension dictionaries

This commit is contained in:
Mathieu Pillard 2018-08-07 16:29:06 +02:00
Родитель 7c6df776cc
Коммит 245dfa96db
4 изменённых файлов: 27 добавлений и 10 удалений

Просмотреть файл

@ -39,7 +39,8 @@ class Command(BaseCommand):
"""Return a queryset with the Version instances that should be
considered for auto approval."""
return (Version.objects.filter(
addon__type__in=(amo.ADDON_EXTENSION, amo.ADDON_LPAPP),
addon__type__in=(
amo.ADDON_EXTENSION, amo.ADDON_LPAPP, amo.ADDON_DICT),
addon__disabled_by_user=False,
addon__status__in=(amo.STATUS_PUBLIC, amo.STATUS_NOMINATED),
files__status=amo.STATUS_AWAITING_REVIEW,

Просмотреть файл

@ -70,7 +70,7 @@ class TestAutoApproveCommand(TestCase):
# Even add an empty reviewer flags instance, that should not matter.
AddonReviewerFlags.objects.create(addon=new_addon)
# Add langpack: it should also be considered.
# Add langpack: it should be considered.
langpack = addon_factory(
type=amo.ADDON_LPAPP, status=amo.STATUS_NOMINATED, file_kw={
'status': amo.STATUS_AWAITING_REVIEW,
@ -78,6 +78,14 @@ class TestAutoApproveCommand(TestCase):
langpack_version = langpack.versions.all()[0]
langpack_version.update(nomination=self.days_ago(3))
# Add a dictionary: it should also be considered.
dictionary = addon_factory(
type=amo.ADDON_DICT, status=amo.STATUS_NOMINATED, file_kw={
'status': amo.STATUS_AWAITING_REVIEW,
'is_webextension': True})
dictionary_version = dictionary.versions.all()[0]
dictionary_version.update(nomination=self.days_ago(4))
# Add a bunch of add-ons in various states that should not be returned.
# Public add-on with no updates.
addon_factory(file_kw={'is_webextension': True})
@ -128,13 +136,15 @@ class TestAutoApproveCommand(TestCase):
command.post_review = True
qs = command.fetch_candidates()
# 3 versions should be found. Because of the nomination date,
# langpack_version should be first (its nomination date is the oldest),
# followed by new_addon_version and then self.version.
assert len(qs) == 3
assert qs[0] == langpack_version
assert qs[1] == new_addon_version
assert qs[2] == self.version
# 4 versions should be found. Because of the nomination date,
# dictionary_version should be first (its nomination date is the
# oldest) followed by langpack_version, new_addon_version and then
# self.version.
assert len(qs) == 4
assert qs[0] == dictionary_version
assert qs[1] == langpack_version
assert qs[2] == new_addon_version
assert qs[3] == self.version
@mock.patch(
'olympia.reviewers.management.commands.auto_approve.statsd.incr')

Просмотреть файл

@ -638,7 +638,8 @@ class Version(OnChangeMixin, ModelBase):
auto_approve command."""
return (
self.addon.status in (amo.STATUS_PUBLIC, amo.STATUS_NOMINATED) and
self.addon.type in (amo.ADDON_EXTENSION, amo.ADDON_LPAPP) and
self.addon.type in (
amo.ADDON_EXTENSION, amo.ADDON_LPAPP, amo.ADDON_DICT) and
self.is_webextension and
self.is_unreviewed and
self.channel == amo.RELEASE_CHANNEL_LISTED)

Просмотреть файл

@ -502,12 +502,17 @@ class TestVersion(TestCase):
AddonReviewerFlags.objects.create(
addon=addon, auto_approval_disabled=False)
assert version.is_ready_for_auto_approval
addon.type = amo.ADDON_THEME
assert not version.is_ready_for_auto_approval
addon.type = amo.ADDON_LPAPP
assert version.is_ready_for_auto_approval
addon.type = amo.ADDON_DICT
assert version.is_ready_for_auto_approval
def test_is_ready_for_auto_approval_addon_status(self):
addon = Addon.objects.get(id=3615)
addon.status = amo.STATUS_NOMINATED