launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #32437
[Merge] ~ilkeremrekoc/launchpad:fix-all-recipe-links into launchpad:master
İlker Emre Koç has proposed merging ~ilkeremrekoc/launchpad:fix-all-recipe-links into launchpad:master.
Commit message:
Fix the link enablement tests
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~ilkeremrekoc/launchpad/+git/launchpad/+merge/485297
The link enablement change had affected tests in various places across
Launchpad. Since that commit changed the logic behind the link
enablement by making all the recipe links available, I had to change
these tests to also expect enabled links all the time.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~ilkeremrekoc/launchpad:fix-all-recipe-links into launchpad:master.
diff --git a/lib/lp/charms/browser/tests/test_charmrecipelisting.py b/lib/lp/charms/browser/tests/test_charmrecipelisting.py
index e37f3b8..f823c4c 100644
--- a/lib/lp/charms/browser/tests/test_charmrecipelisting.py
+++ b/lib/lp/charms/browser/tests/test_charmrecipelisting.py
@@ -12,6 +12,8 @@ from zope.security.proxy import removeSecurityProxy
from lp.charms.interfaces.charmrecipe import CHARM_RECIPE_ALLOW_CREATE
from lp.code.tests.helpers import GitHostingFixture
+from lp.registry.interfaces.person import IPerson
+from lp.registry.interfaces.product import IProduct
from lp.services.database.constants import ONE_DAY_AGO, UTC_NOW
from lp.services.features.testing import MemoryFeatureFixture
from lp.services.webapp import canonical_url
@@ -45,7 +47,14 @@ class TestCharmRecipeListing(BrowserTestCase):
attrs={"href": expected_href},
)
)
- self.assertThat(self.getViewBrowser(context).contents, Not(matcher))
+
+ if IPerson.providedBy(context) or IProduct.providedBy(context):
+ self.assertThat(self.getViewBrowser(context).contents, matcher)
+ else:
+ self.assertThat(
+ self.getViewBrowser(context).contents, Not(matcher)
+ )
+
login(ANONYMOUS)
with MemoryFeatureFixture({CHARM_RECIPE_ALLOW_CREATE: "on"}):
self.factory.makeCharmRecipe(**kwargs)
diff --git a/lib/lp/code/browser/tests/test_product.py b/lib/lp/code/browser/tests/test_product.py
index 3e7a3b2..864f3bf 100644
--- a/lib/lp/code/browser/tests/test_product.py
+++ b/lib/lp/code/browser/tests/test_product.py
@@ -466,7 +466,7 @@ class TestProductOverviewLinks(TestCaseWithFactory):
self.assertIn("View snap packages", text)
self.assertIn("Create snap package", text)
- def test_hides_list_snaps_if_no_snap_is_available(self):
+ def test_shows_list_snaps_link_if_no_snap_is_available(self):
project = self.factory.makeProduct()
browser = self.getUserBrowser(
@@ -477,7 +477,7 @@ class TestProductOverviewLinks(TestCaseWithFactory):
)
# Search link should not be available.
- self.assertNotIn("View snap packages", text)
+ self.assertIn("View snap packages", text)
self.assertIn("Create snap package", text)
def test_displays_create_and_list_oci_project_link_for_owner(self):
diff --git a/lib/lp/registry/browser/tests/test_person.py b/lib/lp/registry/browser/tests/test_person.py
index 47a580c..a7124c7 100644
--- a/lib/lp/registry/browser/tests/test_person.py
+++ b/lib/lp/registry/browser/tests/test_person.py
@@ -634,7 +634,7 @@ class TestPersonIndexView(BrowserTestCase):
markup = self.get_markup(view, person)
self.assertThat(markup, link_match)
- def test_hides_oci_recipes_link_if_user_doesnt_have_oci_recipes(self):
+ def test_shows_oci_recipes_link_if_user_doesnt_have_oci_recipes(self):
self.useFixture(FeatureFixture({OCI_RECIPE_ALLOW_CREATE: "on"}))
person = self.factory.makePerson()
# Creates a recipe from another user, just to make sure it will not
@@ -652,11 +652,11 @@ class TestPersonIndexView(BrowserTestCase):
text="View OCI recipes",
)
)
- self.assertThat(markup, Not(link_match))
+ self.assertThat(markup, link_match)
login(ANONYMOUS)
markup = self.get_markup(view, person)
- self.assertThat(markup, Not(link_match))
+ self.assertThat(markup, link_match)
def test_ppas_query_count(self):
owner = self.factory.makePerson()
diff --git a/lib/lp/registry/browser/tests/test_team.py b/lib/lp/registry/browser/tests/test_team.py
index bd6cb8d..1d82687 100644
--- a/lib/lp/registry/browser/tests/test_team.py
+++ b/lib/lp/registry/browser/tests/test_team.py
@@ -1018,7 +1018,7 @@ class TestTeamIndexView(TestCaseWithFactory):
browser = self.getUserBrowser(team_url, user=None)
self.assertThat(browser.contents, link_match)
- def test_hides_oci_recipes_link_if_user_doesnt_have_oci_recipes(self):
+ def test_shows_oci_recipes_link_if_user_doesnt_have_oci_recipes(self):
self.useFixture(FeatureFixture({OCI_RECIPE_ALLOW_CREATE: "on"}))
member = self.factory.makePerson()
team = self.factory.makeTeam(owner=member, members=[member])
@@ -1040,10 +1040,10 @@ class TestTeamIndexView(TestCaseWithFactory):
text="View OCI recipes",
)
)
- self.assertThat(browser.contents, Not(link_match))
+ self.assertThat(browser.contents, link_match)
browser = self.getUserBrowser(team_url, user=None)
- self.assertThat(browser.contents, Not(link_match))
+ self.assertThat(browser.contents, link_match)
class TestPersonIndexVisibilityView(TestCaseWithFactory):
diff --git a/lib/lp/snappy/browser/tests/test_snaplisting.py b/lib/lp/snappy/browser/tests/test_snaplisting.py
index 90464bb..401e587 100644
--- a/lib/lp/snappy/browser/tests/test_snaplisting.py
+++ b/lib/lp/snappy/browser/tests/test_snaplisting.py
@@ -11,6 +11,8 @@ from testtools.matchers import MatchesAll, Not
from zope.security.proxy import removeSecurityProxy
from lp.code.tests.helpers import GitHostingFixture
+from lp.registry.interfaces.person import IPerson
+from lp.registry.interfaces.product import IProduct
from lp.services.database.constants import ONE_DAY_AGO, SEVEN_DAYS_AGO, UTC_NOW
from lp.services.webapp import canonical_url
from lp.testing import (
@@ -43,7 +45,14 @@ class TestSnapListing(BrowserTestCase):
attrs={"href": expected_href},
)
)
- self.assertThat(self.getViewBrowser(context).contents, Not(matcher))
+
+ if IPerson.providedBy(context) or IProduct.providedBy(context):
+ self.assertThat(self.getViewBrowser(context).contents, matcher)
+ else:
+ self.assertThat(
+ self.getViewBrowser(context).contents, Not(matcher)
+ )
+
login(ANONYMOUS)
self.factory.makeSnap(**kwargs)
self.factory.makeSnap(**kwargs)