From d4707ca31dcc144ee8b5ff3f6a3cf73be7264fe9 Mon Sep 17 00:00:00 2001 From: Christina Lin <44586776+chrstinalin@users.noreply.github.com> Date: Wed, 20 Nov 2024 16:15:45 -0500 Subject: [PATCH] naming --- src/olympia/addons/tests/test_models.py | 2 +- .../devhub/new-landing/components/my-addons.html | 6 +++--- src/olympia/devhub/tests/test_views_versions.py | 2 +- src/olympia/hero/tests/test_models.py | 6 +++--- src/olympia/promoted/tests/test_admin.py | 6 +++--- src/olympia/promoted/tests/test_models.py | 10 +++++----- src/olympia/reviewers/tests/test_utils.py | 4 ++-- src/olympia/versions/tests/test_models.py | 12 ++++++------ 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/olympia/addons/tests/test_models.py b/src/olympia/addons/tests/test_models.py index c372e4fe5c..7bb240a568 100644 --- a/src/olympia/addons/tests/test_models.py +++ b/src/olympia/addons/tests/test_models.py @@ -1834,7 +1834,7 @@ class TestAddonModels(TestCase): # it's in the collection, so is now promoted. assert addon.promoted assert addon.promoted.addon == addon - assert RECOMMENDED in addon.promoted.groups + assert addon.promoted.in_group(RECOMMENDED) assert addon.promoted.application_id is None # This PromotedAddon instance is not a saved one. assert addon.promoted.id is None diff --git a/src/olympia/devhub/templates/devhub/new-landing/components/my-addons.html b/src/olympia/devhub/templates/devhub/new-landing/components/my-addons.html index cb8cad2e43..bdac89f35d 100644 --- a/src/olympia/devhub/templates/devhub/new-landing/components/my-addons.html +++ b/src/olympia/devhub/templates/devhub/new-landing/components/my-addons.html @@ -1,9 +1,9 @@ {% macro render_status(addon) %} - {% set promoted_group = addon.promoted_groups() %} + {% set promoted_groups = addon.promoted_groups() %} {% if addon.status != amo.STATUS_DISABLED and addon.disabled_by_user %} {% set status_text = _('Invisible') %} - {% elif addon.status == amo.STATUS_APPROVED and promoted_group.badged %} - {% set status_text = _('Approved and %s' % promoted_group.name) %} + {% elif addon.status == amo.STATUS_APPROVED and promoted_groups.badged %} + {% set status_text = _('Approved and %s' % promoted_groups.name) %} {% else %} {% set status_text = addon.get_status_display() %} {% endif %} diff --git a/src/olympia/devhub/tests/test_views_versions.py b/src/olympia/devhub/tests/test_views_versions.py index d1b5791e10..d347e3f4ed 100644 --- a/src/olympia/devhub/tests/test_views_versions.py +++ b/src/olympia/devhub/tests/test_views_versions.py @@ -238,7 +238,7 @@ class TestVersion(TestCase): self.addon.reload() assert self.addon.current_version == previous_version # It's still recommended. - assert RECOMMENDED in self.addon.promoted_groups() + assert self.addon.promoted_groups().in_group(RECOMMENDED) def test_can_still_disable_or_delete_old_version_recommended(self): # If the add-on is recommended, you can still disable or delete older diff --git a/src/olympia/hero/tests/test_models.py b/src/olympia/hero/tests/test_models.py index 133850268a..2d190ba66a 100644 --- a/src/olympia/hero/tests/test_models.py +++ b/src/olympia/hero/tests/test_models.py @@ -58,7 +58,7 @@ class TestPrimaryHero(TestCase): ph.promoted_addon.approve_for_version(ph.promoted_addon.addon.current_version) ph.reload() ph.enabled = True - assert RECOMMENDED in ph.promoted_addon.addon.promoted_groups() + assert ph.promoted_addon.addon.promoted_groups().in_group(RECOMMENDED) ph.clean() # it raises if there's an error # change to a different group @@ -66,7 +66,7 @@ class TestPrimaryHero(TestCase): ph.promoted_addon.approve_for_version(ph.promoted_addon.addon.current_version) ph.reload() ph.enabled = True - assert STRATEGIC in ph.promoted_addon.addon.promoted_groups() + assert ph.promoted_addon.addon.promoted_groups().in_group(STRATEGIC) with self.assertRaises(ValidationError) as context: # STRATEGIC isn't a group that can be added as a primary hero ph.clean() @@ -80,7 +80,7 @@ class TestPrimaryHero(TestCase): ph.promoted_addon.approve_for_version(ph.promoted_addon.addon.current_version) ph.reload() ph.enabled = True - assert SPOTLIGHT in ph.promoted_addon.addon.promoted_groups() + assert ph.promoted_addon.addon.promoted_groups().in_group(SPOTLIGHT) ph.clean() # it raises if there's an error def test_clean_external_requires_homepage(self): diff --git a/src/olympia/promoted/tests/test_admin.py b/src/olympia/promoted/tests/test_admin.py index 90803d21f8..f21f617afb 100644 --- a/src/olympia/promoted/tests/test_admin.py +++ b/src/olympia/promoted/tests/test_admin.py @@ -149,7 +149,7 @@ class TestPromotedAddonAdmin(TestCase): assert 'errors' not in response.context_data, response.context_data['errors'] item.reload() assert PromotedAddon.objects.count() == 1 - assert LINE in item.groups + assert item.in_group(LINE) assert PromotedApproval.objects.count() == 4 # same # now it's not promoted because the current_version isn't approved for # LINE group @@ -254,7 +254,7 @@ class TestPromotedAddonAdmin(TestCase): item.reload() assert PromotedAddon.objects.count() == 1 - assert RECOMMENDED in item.groups + assert item.in_group(RECOMMENDED) assert PromotedApproval.objects.count() == 1 # Try to delete the approval instead @@ -337,7 +337,7 @@ class TestPromotedAddonAdmin(TestCase): assert PromotedAddon.objects.count() == 1 item = PromotedAddon.objects.get() assert item.addon == addon - assert RECOMMENDED in item.groups + assert item.in_group(RECOMMENDED) assert item.application_id is None assert item.all_applications == [amo.FIREFOX, amo.ANDROID] assert PromotedApproval.objects.count() == 0 # we didn't create any diff --git a/src/olympia/promoted/tests/test_models.py b/src/olympia/promoted/tests/test_models.py index 5c96e23bbb..b3986eb792 100644 --- a/src/olympia/promoted/tests/test_models.py +++ b/src/olympia/promoted/tests/test_models.py @@ -21,7 +21,7 @@ class TestPromotedAddon(TestCase): promoted_addon = PromotedAddon.objects.create( addon=addon_factory(), group_id=promoted.LINE.id ) - assert promoted.LINE in promoted_addon.groups + assert promoted_addon.in_group(promoted.LINE) assert promoted_addon.application_id is None assert promoted_addon.all_applications == [ applications.FIREFOX, @@ -74,7 +74,7 @@ class TestPromotedAddon(TestCase): promo = PromotedAddon.objects.create( addon=addon_factory(), application_id=amo.FIREFOX.id ) - assert not promo.groups + assert promo.not_promoted assert promo.approved_applications == [] assert not PromotedApproval.objects.exists() @@ -84,7 +84,7 @@ class TestPromotedAddon(TestCase): promo.addon.reload() assert promo.approved_applications == [] assert not PromotedApproval.objects.exists() - assert not promo.addon.promoted_groups() + assert not promo.addon.promoted_groups().not_promoted # then with a group thats immediate_approval == True promo.group_id = promoted.SPOTLIGHT.id @@ -92,7 +92,7 @@ class TestPromotedAddon(TestCase): promo.addon.reload() assert promo.approved_applications == [amo.FIREFOX] assert PromotedApproval.objects.count() == 1 - assert promoted.SPOTLIGHT in promo.addon.promoted_groups() + assert promo.addon.promoted_groups().in_group(promoted.SPOTLIGHT) # test the edge case where the application was changed afterwards promo.application_id = 0 @@ -285,7 +285,7 @@ class TestPromotedAddon(TestCase): # SPOTLIGHT doesnt have special signing states so won't be resigned # approve_for_addon is called automatically - SPOTLIGHT has immediate_approval promo.addon.reload() - assert promoted.SPOTLIGHT in promo.addon.promoted_groups() + assert promo.addon.promoted_groups().in_group(promoted.SPOTLIGHT) assert promo.addon.current_version.version == '0.123a' def test_signal(self): diff --git a/src/olympia/reviewers/tests/test_utils.py b/src/olympia/reviewers/tests/test_utils.py index d1d06fa9a1..8ea2358d48 100644 --- a/src/olympia/reviewers/tests/test_utils.py +++ b/src/olympia/reviewers/tests/test_utils.py @@ -3042,7 +3042,7 @@ class TestReviewHelper(TestReviewHelperBase): assert self.addon.current_version.promoted_approvals.filter( group_id=RECOMMENDED.id ).exists() - assert RECOMMENDED in self.addon.promoted_groups() + assert self.addon.promoted_groups().in_group(RECOMMENDED) def test_nominated_to_approved_other_promoted(self): self.make_addon_promoted(self.addon, LINE) @@ -3060,7 +3060,7 @@ class TestReviewHelper(TestReviewHelperBase): assert self.addon.current_version.promoted_approvals.filter( group_id=RECOMMENDED.id ).exists() - assert RECOMMENDED in self.addon.promoted_groups() + assert self.addon.promoted_groups().in_group(RECOMMENDED) def test_approved_update_other_promoted(self): self.make_addon_promoted(self.addon, LINE) diff --git a/src/olympia/versions/tests/test_models.py b/src/olympia/versions/tests/test_models.py index ee9c6678e5..65216771b0 100644 --- a/src/olympia/versions/tests/test_models.py +++ b/src/olympia/versions/tests/test_models.py @@ -1357,7 +1357,7 @@ class TestVersion(AMOPaths, TestCase): self.make_addon_promoted(addon, RECOMMENDED, approve_version=True) addon = addon.reload() - assert RECOMMENDED in addon.promoted_groups() + addon.promoted_groups().in_group(RECOMMENDED) # But a promoted one, that's in a prereview group, can't be disabled assert not addon.current_version.can_be_disabled_and_deleted() @@ -1400,19 +1400,19 @@ class TestVersion(AMOPaths, TestCase): assert version_b.can_be_disabled_and_deleted() assert version_c.can_be_disabled_and_deleted() assert version_d.can_be_disabled_and_deleted() - assert RECOMMENDED in addon.promoted_groups() + addon.promoted_groups().in_group(RECOMMENDED) # now un-approve version_b version_b.promoted_approvals.update(group_id=NOT_PROMOTED.id) assert version_a.can_be_disabled_and_deleted() assert version_b.can_be_disabled_and_deleted() assert version_c.can_be_disabled_and_deleted() assert not version_d.can_be_disabled_and_deleted() - assert RECOMMENDED in addon.promoted_groups() + addon.promoted_groups().in_group(RECOMMENDED) def test_unbadged_non_prereview_promoted_can_be_disabled_and_deleted(self): addon = Addon.objects.get(id=3615) self.make_addon_promoted(addon, LINE, approve_version=True) - assert LINE in addon.promoted_groups() + assert addon.promoted_groups().in_group(LINE) # it's the only version of a group that requires pre-review and is # badged, so can't be deleted. assert not addon.current_version.can_be_disabled_and_deleted() @@ -1421,13 +1421,13 @@ class TestVersion(AMOPaths, TestCase): addon.promotedaddon.update(group_id=STRATEGIC.id) addon.current_version.promoted_approvals.update(group_id=STRATEGIC.id) del addon.current_version.approved_for_groups - assert STRATEGIC in addon.promoted_groups() + assert addon.promoted_groups().in_group(STRATEGIC) assert addon.current_version.can_be_disabled_and_deleted() # SPOTLIGHT is pre-reviewed but not badged, so it's okay too addon.promotedaddon.update(group_id=SPOTLIGHT.id) addon.current_version.promoted_approvals.update(group_id=SPOTLIGHT.id) - assert SPOTLIGHT in addon.promoted_groups() + assert addon.promoted_groups().in_group(SPOTLIGHT) assert addon.current_version.can_be_disabled_and_deleted() def test_can_be_disabled_and_deleted_querycount(self):