refactor
This commit is contained in:
Родитель
d4707ca31d
Коммит
cf15f082bd
|
@ -1747,54 +1747,54 @@ class TestAddonModels(TestCase):
|
|||
def test_promoted_group(self):
|
||||
addon = addon_factory()
|
||||
# default case - no group so not recommended
|
||||
assert not addon.promoted_group()
|
||||
assert not addon.promoted_groups()
|
||||
# NOT_PROMOTED is falsey
|
||||
assert addon.promoted_group() == NOT_PROMOTED
|
||||
assert not addon.promoted_group(currently_approved=False)
|
||||
assert addon.promoted_groups().not_promoted
|
||||
assert not addon.promoted_groups(currently_approved=False)
|
||||
|
||||
# It's promoted but nothing has been approved
|
||||
promoted = PromotedAddon.objects.create(addon=addon, group_id=LINE.id)
|
||||
assert addon.promoted_group(currently_approved=False)
|
||||
assert addon.promoted_group() == NOT_PROMOTED
|
||||
assert not addon.promoted_group()
|
||||
assert addon.promoted_groups(currently_approved=False)
|
||||
assert addon.promoted_groups().not_promoted
|
||||
assert not addon.promoted_groups()
|
||||
|
||||
# The latest version is approved for the same group.
|
||||
promoted.approve_for_version(version=addon.current_version)
|
||||
assert addon.promoted_group()
|
||||
assert addon.promoted_group() == LINE
|
||||
assert addon.promoted_groups()
|
||||
assert addon.promoted_groups().in_group(LINE)
|
||||
|
||||
# if the group has changes the approval for the current version isn't
|
||||
# valid
|
||||
promoted.update(group_id=SPOTLIGHT.id)
|
||||
assert not addon.promoted_group()
|
||||
assert addon.promoted_group(currently_approved=False)
|
||||
assert addon.promoted_group(currently_approved=False) == SPOTLIGHT
|
||||
assert not addon.promoted_groups()
|
||||
assert addon.promoted_groups(currently_approved=False)
|
||||
assert addon.promoted_groups(currently_approved=False).in_group(SPOTLIGHT)
|
||||
|
||||
promoted.approve_for_version(version=addon.current_version)
|
||||
assert addon.promoted_group() == SPOTLIGHT
|
||||
assert addon.promoted_groups().in_group(SPOTLIGHT)
|
||||
|
||||
# Application specific group membership should work too
|
||||
# if no app is specifed in the PromotedAddon everything should match
|
||||
assert addon.promoted_group() == SPOTLIGHT
|
||||
assert addon.promoted_groups().in_group(SPOTLIGHT)
|
||||
# update to mobile app
|
||||
promoted.update(application_id=amo.ANDROID.id)
|
||||
assert addon.promoted_group()
|
||||
assert addon.promoted_groups()
|
||||
# but if there's no approval for Android it's not promoted
|
||||
addon.current_version.promoted_approvals.filter(
|
||||
application_id=amo.ANDROID.id
|
||||
).delete()
|
||||
del addon.current_version.approved_for_groups
|
||||
assert not addon.promoted_group()
|
||||
assert not addon.promoted_groups()
|
||||
promoted.update(application_id=amo.FIREFOX.id)
|
||||
assert addon.promoted_group() == SPOTLIGHT
|
||||
assert addon.promoted_groups().in_group(SPOTLIGHT)
|
||||
|
||||
# check it doesn't error if there's no current_version
|
||||
addon.current_version.file.update(status=amo.STATUS_DISABLED)
|
||||
addon.update_version()
|
||||
assert not addon.current_version
|
||||
assert not addon.promoted_group()
|
||||
assert addon.promoted_group() == NOT_PROMOTED
|
||||
assert addon.promoted_group(currently_approved=False)
|
||||
assert not addon.promoted_groups()
|
||||
assert addon.promoted_groups().not_promoted
|
||||
assert addon.promoted_groups(currently_approved=False)
|
||||
|
||||
def test_promoted(self):
|
||||
addon = addon_factory()
|
||||
|
|
|
@ -5610,7 +5610,7 @@ class TestAddonSearchView(ESTestCase):
|
|||
slug='my-addon', name='Featured Addôn', promoted=RECOMMENDED
|
||||
)
|
||||
addon_factory(slug='other-addon', name='Other Addôn')
|
||||
assert addon.promoted_group() == RECOMMENDED
|
||||
assert addon.promoted_groups().in_group(RECOMMENDED)
|
||||
self.reindex(Addon)
|
||||
|
||||
data = self.perform_search(self.url, {'featured': 'true'})
|
||||
|
@ -5633,7 +5633,7 @@ class TestAddonSearchView(ESTestCase):
|
|||
min=av_min,
|
||||
max=av_max,
|
||||
)
|
||||
assert addon.promoted_group() == RECOMMENDED
|
||||
assert addon.promoted_groups().in_group(RECOMMENDED)
|
||||
assert addon.promotedaddon.application_id is None # i.e. all
|
||||
assert addon.promotedaddon.approved_applications == [amo.FIREFOX, amo.ANDROID]
|
||||
|
||||
|
@ -5646,7 +5646,7 @@ class TestAddonSearchView(ESTestCase):
|
|||
)
|
||||
# This case is approved for all apps, but now only set for Firefox
|
||||
addon2.promotedaddon.update(application_id=amo.FIREFOX.id)
|
||||
assert addon2.promoted_group() == RECOMMENDED
|
||||
assert addon2.promoted_groups().in_group(RECOMMENDED)
|
||||
assert addon2.promotedaddon.application_id is amo.FIREFOX.id
|
||||
assert addon2.promotedaddon.approved_applications == [amo.FIREFOX]
|
||||
|
||||
|
@ -5671,7 +5671,7 @@ class TestAddonSearchView(ESTestCase):
|
|||
addon4.promotedaddon.update(application_id=amo.FIREFOX.id)
|
||||
addon4.promotedaddon.approve_for_version(addon4.current_version)
|
||||
addon4.promotedaddon.update(application_id=None)
|
||||
assert addon4.promoted_group() == RECOMMENDED
|
||||
assert addon4.promoted_groups().in_group(RECOMMENDED)
|
||||
assert addon4.promotedaddon.application_id is None # i.e. all
|
||||
assert addon4.promotedaddon.approved_applications == [amo.FIREFOX]
|
||||
|
||||
|
@ -5687,7 +5687,7 @@ class TestAddonSearchView(ESTestCase):
|
|||
addon5.promotedaddon.update(application_id=amo.ANDROID.id)
|
||||
addon5.promotedaddon.approve_for_version(addon5.current_version)
|
||||
addon5.promotedaddon.update(application_id=None)
|
||||
assert addon5.promoted_group() == RECOMMENDED
|
||||
assert addon5.promoted_groups().in_group(RECOMMENDED)
|
||||
assert addon5.promotedaddon.application_id is None # i.e. all
|
||||
assert addon5.promotedaddon.approved_applications == [amo.ANDROID]
|
||||
|
||||
|
@ -6555,8 +6555,8 @@ class TestAddonFeaturedView(ESTestCase):
|
|||
def test_basic(self):
|
||||
addon1 = addon_factory(promoted=RECOMMENDED)
|
||||
addon2 = addon_factory(promoted=RECOMMENDED)
|
||||
assert addon1.promoted_group() == RECOMMENDED
|
||||
assert addon2.promoted_group() == RECOMMENDED
|
||||
assert addon1.promoted_groups().in_group(RECOMMENDED)
|
||||
assert addon2.promoted_groups().in_group(RECOMMENDED)
|
||||
addon_factory() # not recommended so shouldn't show up
|
||||
self.refresh()
|
||||
|
||||
|
|
|
@ -341,7 +341,7 @@ class TestPromotedAddonAdmin(TestCase):
|
|||
assert item.application_id is None
|
||||
assert item.all_applications == [amo.FIREFOX, amo.ANDROID]
|
||||
assert PromotedApproval.objects.count() == 0 # we didn't create any
|
||||
assert not addon.promoted_group()
|
||||
assert not addon.promoted_groups()
|
||||
|
||||
def test_can_add_when_existing_approval(self):
|
||||
addon = addon_factory(name='unattached')
|
||||
|
@ -376,7 +376,7 @@ class TestPromotedAddonAdmin(TestCase):
|
|||
assert response.status_code == 200
|
||||
assert 'errors' not in response.context_data
|
||||
assert PromotedApproval.objects.count() == 1 # still one
|
||||
assert addon.promoted_group() == LINE # now approved
|
||||
assert addon.promoted_groups().in_group(LINE) # now approved
|
||||
|
||||
def test_cannot_add_without_discovery_edit_permission(self):
|
||||
addon = addon_factory()
|
||||
|
|
|
@ -28,7 +28,7 @@ def test_add_high_adu_extensions_to_notable_tier_absent_or_no_threshold():
|
|||
add_high_adu_extensions_to_notable()
|
||||
|
||||
assert (
|
||||
extension_with_high_adu.reload().promoted_group(currently_approved=False)
|
||||
extension_with_high_adu.reload().promoted_groups(currently_approved=False)
|
||||
== NOT_PROMOTED
|
||||
)
|
||||
|
||||
|
@ -37,7 +37,7 @@ def test_add_high_adu_extensions_to_notable_tier_absent_or_no_threshold():
|
|||
add_high_adu_extensions_to_notable()
|
||||
|
||||
assert (
|
||||
extension_with_high_adu.reload().promoted_group(currently_approved=False)
|
||||
extension_with_high_adu.reload().promoted_groups(currently_approved=False)
|
||||
== NOT_PROMOTED
|
||||
)
|
||||
|
||||
|
@ -95,23 +95,23 @@ def test_add_high_adu_extensions_to_notable():
|
|||
add_high_adu_extensions_to_notable()
|
||||
|
||||
assert (
|
||||
extension_with_low_adu.reload().promoted_group(currently_approved=False)
|
||||
extension_with_low_adu.reload().promoted_groups(currently_approved=False)
|
||||
== NOT_PROMOTED
|
||||
)
|
||||
assert (
|
||||
extension_with_high_adu.reload().promoted_group(currently_approved=False)
|
||||
extension_with_high_adu.reload().promoted_groups(currently_approved=False)
|
||||
== NOTABLE
|
||||
)
|
||||
assert (
|
||||
ignored_theme.reload().promoted_group(currently_approved=False) == NOT_PROMOTED
|
||||
ignored_theme.reload().promoted_groups(currently_approved=False).not_promoted
|
||||
)
|
||||
already_promoted.reload().promotedaddon.reload()
|
||||
assert already_promoted.promoted_group(currently_approved=False) == LINE
|
||||
assert already_promoted.promoted_groups(currently_approved=False).in_group(LINE)
|
||||
promoted_record_exists.reload().promotedaddon.reload()
|
||||
assert promoted_record_exists.promoted_group(currently_approved=False) == NOTABLE
|
||||
assert unlisted_only_extension.promoted_group(currently_approved=False) == NOTABLE
|
||||
assert mixed_extension.promoted_group(currently_approved=False) == NOTABLE
|
||||
assert deleted_extension.promoted_group(currently_approved=False) == NOTABLE
|
||||
assert promoted_record_exists.promoted_groups(currently_approved=False).in_group(NOTABLE)
|
||||
assert unlisted_only_extension.promoted_groups(currently_approved=False).in_group(NOTABLE)
|
||||
assert mixed_extension.promoted_groups(currently_approved=False).in_group(NOTABLE)
|
||||
assert deleted_extension.promoted_groups(currently_approved=False).in_group(NOTABLE)
|
||||
|
||||
generator = get_staggered_review_due_date_generator(starting=now)
|
||||
|
||||
|
|
|
@ -3765,7 +3765,7 @@ class TestReviewHelperSigning(TestReviewHelperBase):
|
|||
self.setup_data(amo.STATUS_NOMINATED)
|
||||
|
||||
self.make_addon_promoted(self.addon, RECOMMENDED)
|
||||
assert not self.addon.promoted_group()
|
||||
assert not self.addon.promoted_groups()
|
||||
|
||||
self.helper.handler.approve_latest_version()
|
||||
|
||||
|
@ -3775,7 +3775,7 @@ class TestReviewHelperSigning(TestReviewHelperBase):
|
|||
assert self.addon.current_version.promoted_approvals.filter(
|
||||
group_id=RECOMMENDED.id
|
||||
).exists()
|
||||
assert self.addon.promoted_group() == RECOMMENDED
|
||||
assert self.addon.promoted_groups().in_group(RECOMMENDED)
|
||||
|
||||
signature_info, manifest = _get_signature_details(self.file.file.path)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче