launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #29705
[Merge] ~cjwatson/launchpad:rename-dummy-test-classes into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:rename-dummy-test-classes into launchpad:master.
Commit message:
Rename various Dummy* classes in tests
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/437824
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:rename-dummy-test-classes into launchpad:master.
diff --git a/lib/lp/app/tests/test_security.py b/lib/lp/app/tests/test_security.py
index 7c67ad1..384fda1 100644
--- a/lib/lp/app/tests/test_security.py
+++ b/lib/lp/app/tests/test_security.py
@@ -37,13 +37,13 @@ class FakeSecurityAdapter(AuthorizationBase):
self.checkUnauthenticated = FakeMethod()
-class IDummy(Interface):
+class IFake(Interface):
"""Marker interface to test forwarding."""
-@implementer(IDummy)
-class Dummy:
- """An implementation of IDummy."""
+@implementer(IFake)
+class Fake:
+ """An implementation of IFake."""
class TestAuthorizationBase(TestCaseWithFactory):
@@ -65,14 +65,14 @@ class TestAuthorizationBase(TestCaseWithFactory):
def test_forwardCheckAuthenticated_object_changes(self):
# Requesting a check for the same permission on a different object.
permission = self.factory.getUniqueString()
- next_adapter = registerFakeSecurityAdapter(IDummy, permission)
+ next_adapter = registerFakeSecurityAdapter(IFake, permission)
adapter = FakeSecurityAdapter()
adapter.permission = permission
adapter.usedfor = None
adapter.checkPermissionIsRegistered = FakeMethod(result=True)
- adapter.forwardCheckAuthenticated(None, Dummy())
+ adapter.forwardCheckAuthenticated(None, Fake())
self.assertVectorEqual(
(1, adapter.checkPermissionIsRegistered.call_count),
@@ -82,11 +82,11 @@ class TestAuthorizationBase(TestCaseWithFactory):
def test_forwardCheckAuthenticated_permission_changes(self):
# Requesting a check for a different permission on the same object.
next_permission = self.factory.getUniqueString()
- next_adapter = registerFakeSecurityAdapter(IDummy, next_permission)
+ next_adapter = registerFakeSecurityAdapter(IFake, next_permission)
- adapter = FakeSecurityAdapter(Dummy())
+ adapter = FakeSecurityAdapter(Fake())
adapter.permission = self.factory.getUniqueString()
- adapter.usedfor = IDummy
+ adapter.usedfor = IFake
adapter.checkPermissionIsRegistered = FakeMethod(result=True)
adapter.forwardCheckAuthenticated(None, permission=next_permission)
@@ -100,14 +100,14 @@ class TestAuthorizationBase(TestCaseWithFactory):
# Requesting a check for a different permission and a different
# object.
next_permission = self.factory.getUniqueString()
- next_adapter = registerFakeSecurityAdapter(IDummy, next_permission)
+ next_adapter = registerFakeSecurityAdapter(IFake, next_permission)
adapter = FakeSecurityAdapter()
adapter.permission = self.factory.getUniqueString()
adapter.usedfor = None
adapter.checkPermissionIsRegistered = FakeMethod(result=True)
- adapter.forwardCheckAuthenticated(None, Dummy(), next_permission)
+ adapter.forwardCheckAuthenticated(None, Fake(), next_permission)
self.assertVectorEqual(
(1, adapter.checkPermissionIsRegistered.call_count),
@@ -118,10 +118,10 @@ class TestAuthorizationBase(TestCaseWithFactory):
# If the requested forwarding adapter does not exist, return False.
adapter = FakeSecurityAdapter()
adapter.permission = self.factory.getUniqueString()
- adapter.usedfor = IDummy
+ adapter.usedfor = IFake
adapter.checkPermissionIsRegistered = FakeMethod(result=True)
- self.assertFalse(adapter.forwardCheckAuthenticated(None, Dummy()))
+ self.assertFalse(adapter.forwardCheckAuthenticated(None, Fake()))
class TestDelegatedAuthorization(TestCase):
diff --git a/lib/lp/code/xmlrpc/tests/test_git.py b/lib/lp/code/xmlrpc/tests/test_git.py
index 6cd603c..dd4fed2 100644
--- a/lib/lp/code/xmlrpc/tests/test_git.py
+++ b/lib/lp/code/xmlrpc/tests/test_git.py
@@ -104,7 +104,7 @@ def _make_auth_params(
@implementer(IMacaroonIssuer)
-class DummyMacaroonIssuer(MacaroonIssuerBase):
+class FakeMacaroonIssuer(MacaroonIssuerBase):
identifier = "test"
_root_secret = "test"
@@ -1358,7 +1358,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory):
def test_confirm_git_repository_creation_user_mismatch(self):
# confirmRepoCreation refuses macaroons in the case where the user
# doesn't match what the issuer claims was verified.
- issuer = DummyMacaroonIssuer()
+ issuer = FakeMacaroonIssuer()
self.useFixture(
ZopeUtilityFixture(issuer, IMacaroonIssuer, name="test")
@@ -1587,7 +1587,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory):
def test_abort_git_repository_creation_user_mismatch(self):
# confirmRepoCreation refuses macaroons in the case where the user
# doesn't match what the issuer claims was verified.
- issuer = DummyMacaroonIssuer()
+ issuer = FakeMacaroonIssuer()
self.useFixture(
ZopeUtilityFixture(issuer, IMacaroonIssuer, name="test")
@@ -2586,11 +2586,11 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory):
def test_translatePath_user_mismatch(self):
# translatePath refuses macaroons in the case where the user doesn't
- # match what the issuer claims was verified. (We use a dummy issuer
+ # match what the issuer claims was verified. (We use a fake issuer
# for this, since this is a stopgap check to defend against issuer
# bugs; and we test read permissions since write permissions for
# internal macaroons are restricted to particular named issuers.)
- issuer = DummyMacaroonIssuer()
+ issuer = FakeMacaroonIssuer()
self.useFixture(
ZopeUtilityFixture(issuer, IMacaroonIssuer, name="test")
)
@@ -2850,10 +2850,10 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory):
def test_getMergeProposalURL_user_mismatch(self):
# getMergeProposalURL refuses macaroons in the case where the
# user doesn't match what the issuer claims was verified. (We use a
- # dummy issuer for this, since this is a stopgap check to defend
+ # fake issuer for this, since this is a stopgap check to defend
# against issuer bugs)
- issuer = DummyMacaroonIssuer()
+ issuer = FakeMacaroonIssuer()
# Claim to be the code-import-job issuer. This is a bit weird, but
# it gets us past the difficulty that only certain named issuers are
# allowed to confer write permissions.
@@ -2951,7 +2951,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory):
# A merge proposal URL from LP to Turnip is not returned for
# code import job as there is no User at the other end.
- issuer = DummyMacaroonIssuer()
+ issuer = FakeMacaroonIssuer()
# Claim to be the code-import-job issuer. This is a bit weird, but
# it gets us past the difficulty that only certain named issuers are
# allowed to confer write permissions.
@@ -3231,10 +3231,10 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory):
def test_notify_set_repack_data_user_mismatch(self):
# notify refuses macaroons in the case where the
# user doesn't match what the issuer claims was verified. (We use a
- # dummy issuer for this, since this is a stopgap check to defend
+ # fake issuer for this, since this is a stopgap check to defend
# against issuer bugs)
- issuer = DummyMacaroonIssuer()
+ issuer = FakeMacaroonIssuer()
# Claim to be the code-import-job issuer. This is a bit weird, but
# it gets us past the difficulty that only certain named issuers are
# allowed to confer write permissions.
@@ -3581,11 +3581,11 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory):
def test_authenticateWithPassword_user_mismatch(self):
# authenticateWithPassword refuses macaroons in the case where the
# user doesn't match what the issuer claims was verified. (We use a
- # dummy issuer for this, since this is a stopgap check to defend
+ # fake issuer for this, since this is a stopgap check to defend
# against issuer bugs; and we test read permissions since write
# permissions for internal macaroons are restricted to particular
# named issuers.)
- issuer = DummyMacaroonIssuer()
+ issuer = FakeMacaroonIssuer()
self.useFixture(
ZopeUtilityFixture(issuer, IMacaroonIssuer, name="test")
)
@@ -3982,9 +3982,9 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory):
def test_checkRefPermissions_user_mismatch(self):
# checkRefPermissions refuses macaroons in the case where the user
# doesn't match what the issuer claims was verified. (We use a
- # dummy issuer for this, since this is a stopgap check to defend
+ # fake issuer for this, since this is a stopgap check to defend
# against issuer bugs.)
- issuer = DummyMacaroonIssuer()
+ issuer = FakeMacaroonIssuer()
# Claim to be the code-import-job issuer. This is a bit weird, but
# it gets us past the difficulty that only certain named issuers are
# allowed to confer write permissions.
diff --git a/lib/lp/registry/tests/test_prf_finder.py b/lib/lp/registry/tests/test_prf_finder.py
index 8f47ba3..cf15279 100644
--- a/lib/lp/registry/tests/test_prf_finder.py
+++ b/lib/lp/registry/tests/test_prf_finder.py
@@ -35,7 +35,7 @@ class FindReleasesTestCase(TestCase):
def test_findReleases(self):
# test that the findReleases() method behaves as expected
- class DummyProductReleaseFinder(ProductReleaseFinder):
+ class FakeProductReleaseFinder(ProductReleaseFinder):
def __init__(self):
ProductReleaseFinder.__init__(self, None, None)
self.seen_products = []
@@ -49,7 +49,7 @@ class FindReleasesTestCase(TestCase):
def handleProduct(self, product_name, filters):
self.seen_products.append((product_name, filters))
- prf = DummyProductReleaseFinder()
+ prf = FakeProductReleaseFinder()
prf.findReleases()
self.assertEqual(len(prf.seen_products), 2)
self.assertEqual(
@@ -171,7 +171,7 @@ class HandleProductTestCase(TestCase):
def test_handleProduct(self):
# test that handleProduct() correctly calls handleRelease()
- class DummyProductReleaseFinder(ProductReleaseFinder):
+ class FakeProductReleaseFinder(ProductReleaseFinder):
def __init__(self, ztm, log):
ProductReleaseFinder.__init__(self, ztm, log)
self.seen_releases = []
@@ -215,7 +215,7 @@ class HandleProductTestCase(TestCase):
fp.close()
logging.basicConfig(level=logging.CRITICAL)
- prf = DummyProductReleaseFinder(None, logging.getLogger())
+ prf = FakeProductReleaseFinder(None, logging.getLogger())
filters = [
FilterPattern(
diff --git a/lib/lp/services/authserver/tests/test_authserver.py b/lib/lp/services/authserver/tests/test_authserver.py
index 2093a92..3234deb 100644
--- a/lib/lp/services/authserver/tests/test_authserver.py
+++ b/lib/lp/services/authserver/tests/test_authserver.py
@@ -136,7 +136,7 @@ class GetUserAndSSHKeysTests(TestCaseWithFactory):
@implementer(IMacaroonIssuer)
-class DummyMacaroonIssuer(MacaroonIssuerBase):
+class FakeMacaroonIssuer(MacaroonIssuerBase):
identifier = "test"
issuable_via_authserver = True
@@ -169,7 +169,7 @@ class MacaroonTests(TestCaseWithFactory):
def setUp(self):
super().setUp()
- self.issuer = DummyMacaroonIssuer()
+ self.issuer = FakeMacaroonIssuer()
self.useFixture(
ZopeUtilityFixture(self.issuer, IMacaroonIssuer, name="test")
)
diff --git a/lib/lp/services/librarianserver/tests/test_db.py b/lib/lp/services/librarianserver/tests/test_db.py
index 66e8909..ce3d499 100644
--- a/lib/lp/services/librarianserver/tests/test_db.py
+++ b/lib/lp/services/librarianserver/tests/test_db.py
@@ -62,7 +62,7 @@ class DBTestCase(TestCase):
@implementer(IMacaroonIssuer)
-class DummyMacaroonIssuer(MacaroonIssuerBase):
+class FakeMacaroonIssuer(MacaroonIssuerBase):
identifier = "test"
_root_secret = "test"
@@ -154,7 +154,7 @@ class TestLibrarianStuff(TestCase):
@defer.inlineCallbacks
def test_getAlias_with_macaroon(self):
# Library.getAlias() uses the authserver to verify macaroons.
- issuer = DummyMacaroonIssuer()
+ issuer = FakeMacaroonIssuer()
self.useFixture(
ZopeUtilityFixture(issuer, IMacaroonIssuer, name="test")
)
@@ -173,7 +173,7 @@ class TestLibrarianStuff(TestCase):
@defer.inlineCallbacks
def test_getAlias_with_wrong_macaroon(self):
# A macaroon for a different LFA doesn't work.
- issuer = DummyMacaroonIssuer()
+ issuer = FakeMacaroonIssuer()
self.useFixture(
ZopeUtilityFixture(issuer, IMacaroonIssuer, name="test")
)
diff --git a/lib/lp/services/webapp/tests/test_authutility.py b/lib/lp/services/webapp/tests/test_authutility.py
index 908cfa3..e124da2 100644
--- a/lib/lp/services/webapp/tests/test_authutility.py
+++ b/lib/lp/services/webapp/tests/test_authutility.py
@@ -29,21 +29,21 @@ from lp.testing.layers import FunctionalLayer
@implementer(IPerson)
-class DummyPerson:
+class FakePerson:
is_valid_person = True
@implementer(IAccount)
-class DummyAccount:
- person = DummyPerson()
+class FakeAccount:
+ person = FakePerson()
-Bruce = LaunchpadPrincipal(42, "bruce", "Bruce", DummyAccount())
+Bruce = LaunchpadPrincipal(42, "bruce", "Bruce", FakeAccount())
Bruce.person = Bruce.account.person
@implementer(IPlacelessLoginSource)
-class DummyPlacelessLoginSource:
+class FakePlacelessLoginSource:
def getPrincipalByLogin(self, id):
return Bruce
@@ -62,7 +62,7 @@ class TestPlacelessAuth(TestCase):
addCheckerPublic()
self.useFixture(
ZopeUtilityFixture(
- DummyPlacelessLoginSource(), IPlacelessLoginSource
+ FakePlacelessLoginSource(), IPlacelessLoginSource
)
)
self.useFixture(
diff --git a/lib/lp/services/worlddata/tests/test_helpers.py b/lib/lp/services/worlddata/tests/test_helpers.py
index 0778540..68a84c4 100644
--- a/lib/lp/services/worlddata/tests/test_helpers.py
+++ b/lib/lp/services/worlddata/tests/test_helpers.py
@@ -20,7 +20,7 @@ from lp.testing.fixture import ZopeAdapterFixture, ZopeUtilityFixture
from lp.testing.layers import BaseLayer, FunctionalLayer
-class DummyLanguage:
+class FakeLanguage:
def __init__(self, code, pluralforms):
self.code = code
self.pluralforms = pluralforms
@@ -28,13 +28,13 @@ class DummyLanguage:
@implementer(ILanguageSet)
-class DummyLanguageSet:
+class FakeLanguageSet:
_languages = {
- "ja": DummyLanguage("ja", 1),
- "es": DummyLanguage("es", 2),
- "fr": DummyLanguage("fr", 3),
- "cy": DummyLanguage("cy", None),
+ "ja": FakeLanguage("ja", 1),
+ "es": FakeLanguage("es", 2),
+ "fr": FakeLanguage("fr", 3),
+ "cy": FakeLanguage("cy", None),
}
def __getitem__(self, key):
@@ -42,56 +42,56 @@ class DummyLanguageSet:
@implementer(IPerson)
-class DummyPerson:
+class FakePerson:
def __init__(self, codes):
self.codes = codes
- all_languages = DummyLanguageSet()
+ all_languages = FakeLanguageSet()
self.languages = [all_languages[code] for code in self.codes]
-dummyPerson = DummyPerson(("es",))
-dummyNoLanguagePerson = DummyPerson(())
+fakePerson = FakePerson(("es",))
+fakeNoLanguagePerson = FakePerson(())
-class DummyResponse:
+class FakeResponse:
def redirect(self, url):
pass
@implementer(IBrowserRequest)
-class DummyRequest:
+class FakeRequest:
def __init__(self, **form_data):
self.form = form_data
self.URL = "http://this.is.a/fake/url"
- self.response = DummyResponse()
+ self.response = FakeResponse()
def get(self, key, default):
raise key
def adaptRequestToLanguages(request):
- return DummyRequestLanguages()
+ return FakeRequestLanguages()
-class DummyRequestLanguages:
+class FakeRequestLanguages:
def getPreferredLanguages(self):
return [
- DummyLanguage("ja", 1),
- DummyLanguage("es", 2),
- DummyLanguage("fr", 3),
+ FakeLanguage("ja", 1),
+ FakeLanguage("es", 2),
+ FakeLanguage("fr", 3),
]
def getLocalLanguages(self):
return [
- DummyLanguage("da", 4),
- DummyLanguage("as", 5),
- DummyLanguage("sr", 6),
+ FakeLanguage("da", 4),
+ FakeLanguage("as", 5),
+ FakeLanguage("sr", 6),
]
@implementer(ILaunchBag)
-class DummyLaunchBag:
+class FakeLaunchBag:
def __init__(self, login=None, user=None):
self.login = login
self.user = user
@@ -103,10 +103,10 @@ class TestPreferredOrRequestLanguages(TestCase):
def test_single_preferred_language(self):
# Test with a person who has a single preferred language.
- self.useFixture(ZopeUtilityFixture(DummyLanguageSet(), ILanguageSet))
+ self.useFixture(ZopeUtilityFixture(FakeLanguageSet(), ILanguageSet))
self.useFixture(
ZopeUtilityFixture(
- DummyLaunchBag("foo.bar@xxxxxxxxxxxxx", dummyPerson),
+ FakeLaunchBag("foo.bar@xxxxxxxxxxxxx", fakePerson),
ILaunchBag,
)
)
@@ -125,16 +125,16 @@ class TestPreferredOrRequestLanguages(TestCase):
)
)
- languages = preferred_or_request_languages(DummyRequest())
+ languages = preferred_or_request_languages(FakeRequest())
self.assertEqual(1, len(languages))
self.assertEqual("es", languages[0].code)
def test_no_preferred_language(self):
# Test with a person who has no preferred language.
- self.useFixture(ZopeUtilityFixture(DummyLanguageSet(), ILanguageSet))
+ self.useFixture(ZopeUtilityFixture(FakeLanguageSet(), ILanguageSet))
self.useFixture(
ZopeUtilityFixture(
- DummyLaunchBag("foo.bar@xxxxxxxxxxxxx", dummyNoLanguagePerson),
+ FakeLaunchBag("foo.bar@xxxxxxxxxxxxx", fakeNoLanguagePerson),
ILaunchBag,
)
)
@@ -153,7 +153,7 @@ class TestPreferredOrRequestLanguages(TestCase):
)
)
- languages = preferred_or_request_languages(DummyRequest())
+ languages = preferred_or_request_languages(FakeRequest())
self.assertEqual(6, len(languages))
self.assertEqual("ja", languages[0].code)
@@ -163,13 +163,13 @@ class TestIsEnglishVariant(TestCase):
layer = BaseLayer
def test_fr(self):
- self.assertFalse(is_english_variant(DummyLanguage("fr", 1)))
+ self.assertFalse(is_english_variant(FakeLanguage("fr", 1)))
def test_en(self):
- self.assertFalse(is_english_variant(DummyLanguage("en", 1)))
+ self.assertFalse(is_english_variant(FakeLanguage("en", 1)))
def test_en_CA(self):
- self.assertTrue(is_english_variant(DummyLanguage("en_CA", 1)))
+ self.assertTrue(is_english_variant(FakeLanguage("en_CA", 1)))
def test_enm(self):
- self.assertFalse(is_english_variant(DummyLanguage("enm", 1)))
+ self.assertFalse(is_english_variant(FakeLanguage("enm", 1)))
diff --git a/lib/lp/testing/tests/test_fixture.py b/lib/lp/testing/tests/test_fixture.py
index 015787a..1fc6328 100644
--- a/lib/lp/testing/tests/test_fixture.py
+++ b/lib/lp/testing/tests/test_fixture.py
@@ -108,7 +108,7 @@ class TestZopeAdapterFixture(TestCase):
@implementer(IMailDelivery)
-class DummyMailer:
+class FakeMailer:
pass
@@ -121,7 +121,7 @@ class TestZopeUtilityFixture(TestCase):
return getGlobalSiteManager().getUtility(IMailDelivery, "Mail")
def test_fixture(self):
- fake = DummyMailer()
+ fake = FakeMailer()
# In BaseLayer there should be no mailer by default.
self.assertRaises(ComponentLookupError, self.getMailer)
with ZopeUtilityFixture(fake, IMailDelivery, "Mail"):
@@ -131,13 +131,13 @@ class TestZopeUtilityFixture(TestCase):
def test_restores_previous_utility(self):
# If there was a previous utility, ZopeUtilityFixture restores it on
# cleanup.
- original_fake = DummyMailer()
+ original_fake = FakeMailer()
getGlobalSiteManager().registerUtility(
original_fake, IMailDelivery, "Mail"
)
try:
self.assertEqual(original_fake, self.getMailer())
- fake = DummyMailer()
+ fake = FakeMailer()
with ZopeUtilityFixture(fake, IMailDelivery, "Mail"):
self.assertEqual(fake, self.getMailer())
self.assertEqual(original_fake, self.getMailer())
diff --git a/lib/lp/testing/tests/test_publication.py b/lib/lp/testing/tests/test_publication.py
index 042629e..582740a 100644
--- a/lib/lp/testing/tests/test_publication.py
+++ b/lib/lp/testing/tests/test_publication.py
@@ -132,7 +132,7 @@ class TestTestTraverse(TestCaseWithFactory):
self.assertIsInstance(view, EntryResource)
-class DummyNavigation(Navigation):
+class FakeNavigation(Navigation):
"""A simple navigation class to test traversal."""
def traverse(self, name):
@@ -149,22 +149,22 @@ class TestStepThrough(TestCaseWithFactory):
layer = FunctionalLayer
def traverse(self, request, name):
- """Traverse to 'segments' using a 'DummyNavigation' object.
+ """Traverse to 'segments' using a 'FakeNavigation' object.
Using the Zope traversal machinery, traverse to the path given by
'segments'.
"""
- traverser = DummyNavigation(object(), request)
+ traverser = FakeNavigation(object(), request)
return traverser.publishTraverse(request, name)
def test_normal_stepthrough(self):
# The stepthrough is processed normally.
- request = FakeLaunchpadRequest(["~dummy"], ["fred"])
+ request = FakeLaunchpadRequest(["~fake"], ["fred"])
self.assertEqual("stepthrough-fred", self.traverse(request, "+step"))
def test_ignored_stepthrough(self):
# The stepthrough is ignored since the next path item is a zope
# namespace.
- request = FakeLaunchpadRequest(["~dummy"], ["++model++"])
+ request = FakeLaunchpadRequest(["~fake"], ["++model++"])
self.assertEqual("+step", self.traverse(request, "+step"))
self.assertEqual("++model++", request.stepstogo.peek())