launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #28877
[Merge] ~cjwatson/launchpad:black-xmlrpc into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:black-xmlrpc into launchpad:master.
Commit message:
lp.xmlrpc: Apply black
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/427290
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:black-xmlrpc into launchpad:master.
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
index 2b86d1c..6ac57c2 100644
--- a/.git-blame-ignore-revs
+++ b/.git-blame-ignore-revs
@@ -94,3 +94,5 @@ cf7c6a08bd010dd260bff4690d64479fadf37e67
c7dedd4d8a3c642f77570e525be0af9714703eba
# apply black to lp.translations
b56a741985ca580c281f142bea589b1ef05d3e93
+# apply black to lp.xmlrpc
+0bf877facbd96ece340dd26a7429ebbf0fb9b65a
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 7aa4211..ffb69fd 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -62,6 +62,7 @@ repos:
|testopenid
|tests
|translations
+ |xmlrpc
)/
- repo: https://github.com/PyCQA/isort
rev: 5.9.2
@@ -100,6 +101,7 @@ repos:
|testopenid
|tests
|translations
+ |xmlrpc
)/
- id: isort
alias: isort-black
@@ -128,6 +130,7 @@ repos:
|testopenid
|tests
|translations
+ |xmlrpc
)/
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
diff --git a/lib/lp/xmlrpc/application.py b/lib/lp/xmlrpc/application.py
index d7b5edb..ec159fd 100644
--- a/lib/lp/xmlrpc/application.py
+++ b/lib/lp/xmlrpc/application.py
@@ -4,24 +4,21 @@
"""XML-RPC API to the application roots."""
__all__ = [
- 'ISelfTest',
- 'PrivateApplication',
- 'SelfTest',
- ]
+ "ISelfTest",
+ "PrivateApplication",
+ "SelfTest",
+]
import xmlrpc.client
from zope.component import getUtility
-from zope.interface import (
- implementer,
- Interface,
- )
+from zope.interface import Interface, implementer
from lp.bugs.interfaces.malone import IPrivateMaloneApplication
from lp.code.interfaces.codehosting import ICodehostingApplication
from lp.code.interfaces.codeimportscheduler import (
ICodeImportSchedulerApplication,
- )
+)
from lp.code.interfaces.gitapi import IGitApplication
from lp.registry.interfaces.mailinglist import IMailingListApplication
from lp.registry.interfaces.person import ICanonicalSSOApplication
@@ -37,7 +34,6 @@ from lp.xmlrpc.interfaces import IPrivateApplication
# the regular expression in lp:lp-dev-utils page-performance-report.ini.
@implementer(IPrivateApplication)
class PrivateApplication:
-
@property
def mailinglists(self):
"""See `IPrivateApplication`."""
@@ -102,14 +98,13 @@ class ISelfTest(Interface):
@implementer(ISelfTest)
class SelfTest(LaunchpadXMLRPCView):
-
def make_fault(self):
"""Returns an xmlrpc fault."""
return xmlrpc.client.Fault(666, "Yoghurt and spanners.")
def concatenate(self, string1, string2):
"""Return the concatenation of the two given strings."""
- return '%s %s' % (string1, string2)
+ return "%s %s" % (string1, string2)
def hello(self):
"""Return a greeting to the logged in user."""
diff --git a/lib/lp/xmlrpc/faults.py b/lib/lp/xmlrpc/faults.py
index 78b7ac2..0b6ad95 100644
--- a/lib/lp/xmlrpc/faults.py
+++ b/lib/lp/xmlrpc/faults.py
@@ -7,47 +7,47 @@
# in this directory.
__all__ = [
- 'BadStatus',
- 'BranchAlreadyRegistered',
- 'BranchCreationForbidden',
- 'BranchNameInUse',
- 'BranchUniqueNameConflict',
- 'CannotHaveLinkedBranch',
- 'FileBugGotProductAndDistro',
- 'FileBugMissingProductOrDistribution',
- 'GitRepositoryNotFound',
- 'InactiveAccount',
- 'InvalidBranchIdentifier',
- 'InvalidBranchName',
- 'InvalidBranchUniqueName',
- 'InvalidBranchUrl',
- 'InvalidPath',
- 'InvalidProductName',
- 'InvalidSourcePackageName',
- 'OopsOccurred',
- 'NoBranchWithID',
- 'NoLinkedBranch',
- 'NoSuchBranch',
- 'NoSuchBug',
- 'NoSuchCodeImportJob',
- 'NoSuchDistribution',
- 'NoSuchDistroSeries',
- 'NoSuchPackage',
- 'NoSuchPerson',
- 'NoSuchPersonWithName',
- 'NoSuchProduct',
- 'NoSuchProductSeries',
- 'NoSuchSourcePackageName',
- 'NoSuchTeamMailingList',
- 'NotFound',
- 'NotInTeam',
- 'NoUrlForBranch',
- 'PathTranslationError',
- 'PermissionDenied',
- 'RequiredParameterMissing',
- 'Unauthorized',
- 'UnexpectedStatusReport',
- ]
+ "BadStatus",
+ "BranchAlreadyRegistered",
+ "BranchCreationForbidden",
+ "BranchNameInUse",
+ "BranchUniqueNameConflict",
+ "CannotHaveLinkedBranch",
+ "FileBugGotProductAndDistro",
+ "FileBugMissingProductOrDistribution",
+ "GitRepositoryNotFound",
+ "InactiveAccount",
+ "InvalidBranchIdentifier",
+ "InvalidBranchName",
+ "InvalidBranchUniqueName",
+ "InvalidBranchUrl",
+ "InvalidPath",
+ "InvalidProductName",
+ "InvalidSourcePackageName",
+ "OopsOccurred",
+ "NoBranchWithID",
+ "NoLinkedBranch",
+ "NoSuchBranch",
+ "NoSuchBug",
+ "NoSuchCodeImportJob",
+ "NoSuchDistribution",
+ "NoSuchDistroSeries",
+ "NoSuchPackage",
+ "NoSuchPerson",
+ "NoSuchPersonWithName",
+ "NoSuchProduct",
+ "NoSuchProductSeries",
+ "NoSuchSourcePackageName",
+ "NoSuchTeamMailingList",
+ "NotFound",
+ "NotInTeam",
+ "NoUrlForBranch",
+ "PathTranslationError",
+ "PermissionDenied",
+ "RequiredParameterMissing",
+ "Unauthorized",
+ "UnexpectedStatusReport",
+]
from lp.services.xmlrpc import LaunchpadFault
@@ -69,8 +69,9 @@ class NoSuchPerson(LaunchpadFault):
error_code = 20
msg_template = (
- 'Invalid %(type)s: No user with the email address '
- '"%(email_address)s" was found')
+ "Invalid %(type)s: No user with the email address "
+ '"%(email_address)s" was found'
+ )
def __init__(self, email_address, type="user"):
LaunchpadFault.__init__(self, type=type, email_address=email_address)
@@ -112,7 +113,8 @@ class FileBugMissingProductOrDistribution(LaunchpadFault):
error_code = 60
msg_template = (
"Required arguments missing. You must specify either a product or "
- "distribution in which the bug exists.")
+ "distribution in which the bug exists."
+ )
class FileBugGotProductAndDistro(LaunchpadFault):
@@ -124,7 +126,8 @@ class FileBugGotProductAndDistro(LaunchpadFault):
error_code = 70
msg_template = (
"Too many arguments. You may specify either a product or a "
- "distribution, but not both.")
+ "distribution, but not both."
+ )
class NoSuchDistribution(LaunchpadFault):
@@ -163,7 +166,8 @@ class BranchCreationForbidden(LaunchpadFault):
error_code = 110
msg_template = (
"You are not allowed to create a branch for project: "
- "%(parameter_name)s")
+ "%(parameter_name)s"
+ )
def __init__(self, parameter_name):
LaunchpadFault.__init__(self, parameter_name=parameter_name)
@@ -193,7 +197,7 @@ class NoSuchTeamMailingList(LaunchpadFault):
"""There is no such team mailing list with the given name."""
error_code = 140
- msg_template = 'No such team mailing list: %(team_name)s'
+ msg_template = "No such team mailing list: %(team_name)s"
def __init__(self, team_name):
LaunchpadFault.__init__(self, team_name=team_name)
@@ -207,8 +211,9 @@ class UnexpectedStatusReport(LaunchpadFault):
"""
error_code = 150
- msg_template = ('Unexpected status report "%(status)s" '
- 'for team: %(team_name)s')
+ msg_template = (
+ 'Unexpected status report "%(status)s" ' "for team: %(team_name)s"
+ )
def __init__(self, team_name, status):
LaunchpadFault.__init__(self, team_name=team_name, status=status)
@@ -228,7 +233,7 @@ class NoLinkedBranch(LaunchpadFault):
"""The object has no branch registered with it."""
error_code = 170
- msg_template = ('%(object_name)s has no default branch.')
+ msg_template = "%(object_name)s has no default branch."
def __init__(self, component):
LaunchpadFault.__init__(self, object_name=component.displayname)
@@ -239,19 +244,20 @@ class NoSuchProductSeries(LaunchpadFault):
error_code = 180
msg_template = (
- 'Project %(product_name)s has no series called "%(series_name)s"')
+ 'Project %(product_name)s has no series called "%(series_name)s"'
+ )
def __init__(self, series_name, product):
LaunchpadFault.__init__(
- self, series_name=series_name, product_name=product.name)
+ self, series_name=series_name, product_name=product.name
+ )
class InvalidBranchIdentifier(LaunchpadFault):
"""The branch identifier didn't begin with a tilde."""
error_code = 190
- msg_template = (
- 'Invalid branch identifier: %(branch_path)r')
+ msg_template = "Invalid branch identifier: %(branch_path)r"
def __init__(self, branch_path):
LaunchpadFault.__init__(self, branch_path=branch_path)
@@ -261,7 +267,7 @@ class NoSuchPersonWithName(LaunchpadFault):
"""There's no Person with the specified name registered in Launchpad."""
error_code = 200
- msg_template = 'No such person or team: %(person_name)s'
+ msg_template = "No such person or team: %(person_name)s"
def __init__(self, person_name):
LaunchpadFault.__init__(self, person_name=person_name)
@@ -287,15 +293,18 @@ class CannotHaveLinkedBranch(LaunchpadFault):
error_code = 230
msg_template = (
"%(component_name)s is a %(component_type)s, and a "
- "%(component_type)s cannot have a default branch.")
+ "%(component_type)s cannot have a default branch."
+ )
def __init__(self, component):
component_type = component.__class__.__name__.lower()
- if component_type == 'projectgroup':
- component_type = 'project group'
+ if component_type == "projectgroup":
+ component_type = "project group"
LaunchpadFault.__init__(
- self, component_name=component.displayname,
- component_type=component_type)
+ self,
+ component_name=component.displayname,
+ component_type=component_type,
+ )
class InvalidProductName(LaunchpadFault):
@@ -320,11 +329,12 @@ class NotInTeam(LaunchpadFault):
"""
error_code = 250
- msg_template = '%(person_name)s is not a member of %(team_name)s.'
+ msg_template = "%(person_name)s is not a member of %(team_name)s."
def __init__(self, person_name, team_name):
LaunchpadFault.__init__(
- self, person_name=person_name, team_name=team_name)
+ self, person_name=person_name, team_name=team_name
+ )
class InvalidBranchName(LaunchpadFault):
@@ -336,10 +346,10 @@ class InvalidBranchName(LaunchpadFault):
error_code = 260
# The actual exception is rather friendly, so we just wrap it in a Fault.
- msg_template = '%(error)s'
+ msg_template = "%(error)s"
def __init__(self, error):
- error_message = error.args[0].encode('utf-8', 'replace')
+ error_message = error.args[0].encode("utf-8", "replace")
LaunchpadFault.__init__(self, error=error_message)
@@ -347,7 +357,7 @@ class NoBranchWithID(LaunchpadFault):
"""There's no branch with the given ID."""
error_code = 270
- msg_template = 'No branch with ID %(branch_id)s'
+ msg_template = "No branch with ID %(branch_id)s"
def __init__(self, branch_id):
LaunchpadFault.__init__(self, branch_id=branch_id)
@@ -357,8 +367,7 @@ class NoUrlForBranch(LaunchpadFault):
"""resolve_lp_path resolved to a remote branch with no URL."""
error_code = 280
- msg_template = (
- 'The remote branch at %(unique_name)s has no URL specified.')
+ msg_template = "The remote branch at %(unique_name)s has no URL specified."
def __init__(self, unique_name):
LaunchpadFault.__init__(self, unique_name=unique_name)
@@ -396,7 +405,8 @@ class InvalidPath(LaunchpadFault):
error_code = 300
msg_template = (
- "Could not translate '%(path)s'. Can only translate absolute paths.")
+ "Could not translate '%(path)s'. Can only translate absolute paths."
+ )
def __init__(self, path):
LaunchpadFault.__init__(self, path=path)
@@ -406,8 +416,7 @@ class PermissionDenied(LaunchpadFault):
"""Raised when a user is denied access to some resource."""
error_code = 310
- msg_template = (
- "%(message)s")
+ msg_template = "%(message)s"
def __init__(self, message="Permission denied."):
LaunchpadFault.__init__(self, message=message)
@@ -417,22 +426,21 @@ class NotFound(LaunchpadFault):
"""Raised when a resource is not found."""
error_code = 320
- msg_template = (
- "%(message)s")
+ msg_template = "%(message)s"
def __init__(self, message="Not found."):
LaunchpadFault.__init__(self, message=message)
class InvalidBranchUniqueName(LaunchpadFault):
- """Raised when a user tries to resolve a unique name that's incomplete.
- """
+ """Raised when a user tries to resolve a unique name that's incomplete."""
error_code = 330
msg_template = (
"~%(path)s is too short to be a branch name. Try "
"'~<owner>/+junk/<branch>', '~<owner>/<product>/<branch> or "
- "'~<owner>/<distribution>/<series>/<sourcepackage>/<branch>'.")
+ "'~<owner>/<distribution>/<series>/<sourcepackage>/<branch>'."
+ )
def __init__(self, path):
self.path = path
@@ -451,8 +459,7 @@ class NoSuchDistroSeries(LaunchpadFault):
class NoSuchSourcePackageName(LaunchpadFault):
- """Raised when the user tries to get a sourcepackage that doesn't exist.
- """
+ """Raised when the user tries to get a sourcepackage that doesn't exist."""
error_code = 350
msg_template = "No such source package %(sourcepackagename)s."
@@ -466,7 +473,7 @@ class NoSuchCodeImportJob(LaunchpadFault):
"""Raised by `ICodeImportScheduler` methods when a job is not found."""
error_code = 360
- msg_template = 'Job %(job_id)d not found.'
+ msg_template = "Job %(job_id)d not found."
def __init__(self, job_id):
LaunchpadFault.__init__(self, job_id=job_id)
@@ -477,8 +484,9 @@ class OopsOccurred(LaunchpadFault):
error_code = 380
msg_template = (
- 'An unexpected error has occurred while %(server_op)s. '
- 'Please report a Launchpad bug and quote: %(oopsid)s.')
+ "An unexpected error has occurred while %(server_op)s. "
+ "Please report a Launchpad bug and quote: %(oopsid)s."
+ )
def __init__(self, server_op, oopsid):
LaunchpadFault.__init__(self, server_op=server_op, oopsid=oopsid)
@@ -488,7 +496,7 @@ class OopsOccurred(LaunchpadFault):
class InvalidSourcePackageName(LaunchpadFault):
error_code = 390
- msg_template = ("%(name)s is not a valid source package name.")
+ msg_template = "%(name)s is not a valid source package name."
def __init__(self, name):
self.name = name
@@ -500,8 +508,7 @@ class Unauthorized(LaunchpadFault):
"""Permission was denied, but authorisation may help."""
error_code = 410
- msg_template = (
- "%(message)s")
+ msg_template = "%(message)s"
def __init__(self, message="Authorisation required."):
LaunchpadFault.__init__(self, message=message)
@@ -511,7 +518,7 @@ class InactiveAccount(LaunchpadFault):
"""The requested Launchpad account is inactive."""
error_code = 420
- msg_template = 'Inactive account: %(person_name)s'
+ msg_template = "Inactive account: %(person_name)s"
def __init__(self, person_name):
LaunchpadFault.__init__(self, person_name=person_name)
diff --git a/lib/lp/xmlrpc/helpers.py b/lib/lp/xmlrpc/helpers.py
index f2c7397..c31bf6e 100644
--- a/lib/lp/xmlrpc/helpers.py
+++ b/lib/lp/xmlrpc/helpers.py
@@ -4,8 +4,8 @@
"""Generic XML-RPC helpers."""
__all__ = [
- 'return_fault',
- ]
+ "return_fault",
+]
from xmlrpc.client import Fault
diff --git a/lib/lp/xmlrpc/interfaces.py b/lib/lp/xmlrpc/interfaces.py
index 6456ab7..a998b2c 100644
--- a/lib/lp/xmlrpc/interfaces.py
+++ b/lib/lp/xmlrpc/interfaces.py
@@ -4,8 +4,8 @@
"""Interfaces for the Launchpad application."""
__all__ = [
- 'IPrivateApplication',
- ]
+ "IPrivateApplication",
+]
from zope.interface import Attribute
@@ -15,7 +15,7 @@ from lp.services.webapp.interfaces import ILaunchpadApplication
class IPrivateApplication(ILaunchpadApplication):
"""Launchpad private XML-RPC application root."""
- archive = Attribute("Archive XML-RPC end point.""")
+ archive = Attribute("Archive XML-RPC end point." "")
authserver = Attribute("""Old Authserver API end point.""")
@@ -27,8 +27,7 @@ class IPrivateApplication(ILaunchpadApplication):
bugs = Attribute("""Launchpad Bugs XML-RPC end point.""")
- canonicalsso = Attribute(
- """Canonical SSO XML-RPC end point.""")
+ canonicalsso = Attribute("""Canonical SSO XML-RPC end point.""")
featureflags = Attribute("""Feature flag information endpoint""")
diff --git a/lib/lp/xmlrpc/tests/test_private_xmlrpc.py b/lib/lp/xmlrpc/tests/test_private_xmlrpc.py
index 7215a23..3b1e31a 100644
--- a/lib/lp/xmlrpc/tests/test_private_xmlrpc.py
+++ b/lib/lp/xmlrpc/tests/test_private_xmlrpc.py
@@ -9,10 +9,7 @@ import xmlrpc.client
from zope.component import getUtility
from lp.services.verification.interfaces.logintoken import ILoginTokenSet
-from lp.testing import (
- anonymous_logged_in,
- TestCase,
- )
+from lp.testing import TestCase, anonymous_logged_in
from lp.testing.layers import LaunchpadFunctionalLayer
from lp.testing.xmlrpc import XMLRPCTestTransport
@@ -27,36 +24,37 @@ class TestPrivateXMLRPC(TestCase):
layer = LaunchpadFunctionalLayer
- public_root = 'http://test@xxxxxxxxxxxxx:test@xxxxxxxxxxxxxxxxxxxxx/'
- private_root = 'http://xmlrpc-private.launchpad.test:8087/'
+ public_root = "http://test@xxxxxxxxxxxxx:test@xxxxxxxxxxxxxxxxxxxxx/"
+ private_root = "http://xmlrpc-private.launchpad.test:8087/"
def get_public_proxy(self, path):
"""Get an xmlrpc.client.ServerProxy pointing at the public URL"""
return xmlrpc.client.ServerProxy(
- self.public_root + path,
- transport=XMLRPCTestTransport())
+ self.public_root + path, transport=XMLRPCTestTransport()
+ )
def get_private_proxy(self, path):
"""Get an xmlrpc.client.ServerProxy pointing at the private URL"""
return xmlrpc.client.ServerProxy(
- self.private_root + path,
- transport=XMLRPCTestTransport())
+ self.private_root + path, transport=XMLRPCTestTransport()
+ )
def test_mailing_lists_not_public(self):
"""For example, the team mailing list feature requires a connection
between an internal Mailman server and Launchpad. This end point is
not available on the external XML-RPC port.
"""
- external_api = self.get_public_proxy('mailinglists/')
- e = self.assertRaises(xmlrpc.client.ProtocolError,
- external_api.getPendingActions)
+ external_api = self.get_public_proxy("mailinglists/")
+ e = self.assertRaises(
+ xmlrpc.client.ProtocolError, external_api.getPendingActions
+ )
self.assertEqual(404, e.errcode)
def test_mailing_lists_internally_available(self):
"""However, the end point is available on the internal port and does
not require authentication.
"""
- internal_api = self.get_private_proxy('mailinglists/')
+ internal_api = self.get_private_proxy("mailinglists/")
self.assertEqual({}, internal_api.getPendingActions())
def test_external_bugs_api(self):
@@ -64,27 +62,29 @@ class TestPrivateXMLRPC(TestCase):
available on the external port.
"""
with anonymous_logged_in():
- external_api = self.get_public_proxy('bugs/')
+ external_api = self.get_public_proxy("bugs/")
bug_dict = dict(
- product='firefox', summary='the summary',
- comment='the comment')
+ product="firefox", summary="the summary", comment="the comment"
+ )
result = external_api.filebug(bug_dict)
- self.assertStartsWith(result, 'http://bugs.launchpad.test/bugs/')
+ self.assertStartsWith(result, "http://bugs.launchpad.test/bugs/")
def test_internal_bugs_api(self):
"""There is an interal bugs api, too, but that doesn't share the same
methods as those exposed publicly.
"""
- internal_api = self.get_private_proxy('bugs/')
+ internal_api = self.get_private_proxy("bugs/")
bug_dict = dict(
- product='firefox', summary='the summary', comment='the comment')
- e = self.assertRaises(xmlrpc.client.ProtocolError,
- internal_api.filebug, bug_dict)
+ product="firefox", summary="the summary", comment="the comment"
+ )
+ e = self.assertRaises(
+ xmlrpc.client.ProtocolError, internal_api.filebug, bug_dict
+ )
self.assertEqual(404, e.errcode)
def test_get_utility(self):
with anonymous_logged_in():
- internal_api = self.get_private_proxy('bugs/')
+ internal_api = self.get_private_proxy("bugs/")
token_string = internal_api.newBugTrackerToken()
token = getUtility(ILoginTokenSet)[token_string]
- self.assertEqual('LoginToken', token.__class__.__name__)
+ self.assertEqual("LoginToken", token.__class__.__name__)
diff --git a/lib/lp/xmlrpc/tests/test_xmlrpc_selftest.py b/lib/lp/xmlrpc/tests/test_xmlrpc_selftest.py
index d4fa40f..4602b11 100644
--- a/lib/lp/xmlrpc/tests/test_xmlrpc_selftest.py
+++ b/lib/lp/xmlrpc/tests/test_xmlrpc_selftest.py
@@ -10,17 +10,14 @@ from zope.component import getUtility
from lp.services.webapp.interfaces import ILaunchBag
from lp.testing import (
+ TestCaseWithFactory,
anonymous_logged_in,
person_logged_in,
- TestCaseWithFactory,
verifyObject,
- )
+)
from lp.testing.layers import LaunchpadFunctionalLayer
from lp.testing.xmlrpc import XMLRPCTestTransport
-from lp.xmlrpc.application import (
- ISelfTest,
- SelfTest,
- )
+from lp.xmlrpc.application import ISelfTest, SelfTest
class TestXMLRPCSelfTest(TestCaseWithFactory):
@@ -29,20 +26,22 @@ class TestXMLRPCSelfTest(TestCaseWithFactory):
def make_proxy(self):
return xmlrpc.client.ServerProxy(
- 'http://xmlrpc.launchpad.test/', transport=XMLRPCTestTransport())
+ "http://xmlrpc.launchpad.test/", transport=XMLRPCTestTransport()
+ )
def make_logged_in_proxy(self):
return xmlrpc.client.ServerProxy(
- 'http://test@xxxxxxxxxxxxx:test@xxxxxxxxxxxxxxxxxxxxx/',
- transport=XMLRPCTestTransport())
+ "http://test@xxxxxxxxxxxxx:test@xxxxxxxxxxxxxxxxxxxxx/",
+ transport=XMLRPCTestTransport(),
+ )
def test_launchpad_root_object(self):
"""The Launchpad root object has a simple XMLRPC API to show that
XMLRPC works.
"""
- selftestview = SelfTest('somecontext', 'somerequest')
+ selftestview = SelfTest("somecontext", "somerequest")
self.assertTrue(verifyObject(ISelfTest, selftestview))
- self.assertEqual('foo bar', selftestview.concatenate('foo', 'bar'))
+ self.assertEqual("foo bar", selftestview.concatenate("foo", "bar"))
fault = selftestview.make_fault()
self.assertEqual("<Fault 666: 'Yoghurt and spanners.'>", str(fault))
@@ -51,7 +50,7 @@ class TestXMLRPCSelfTest(TestCaseWithFactory):
Transport which talks with the publisher directly.
"""
selftest = self.make_proxy()
- self.assertEqual('foo bar', selftest.concatenate('foo', 'bar'))
+ self.assertEqual("foo bar", selftest.concatenate("foo", "bar"))
fault = self.assertRaises(xmlrpc.client.Fault, selftest.make_fault)
self.assertEqual("<Fault 666: 'Yoghurt and spanners.'>", str(fault))
@@ -60,7 +59,7 @@ class TestXMLRPCSelfTest(TestCaseWithFactory):
other than xmlrpc.client.Fault. We have such a method on the self
test view.
"""
- selftestview = SelfTest('somecontext', 'somerequest')
+ selftestview = SelfTest("somecontext", "somerequest")
self.assertRaises(RuntimeError, selftestview.raise_exception)
def test_exception_converted_to_fault(self):
@@ -76,7 +75,7 @@ class TestXMLRPCSelfTest(TestCaseWithFactory):
def test_anonymous_authentication(self):
"""hello() returns Anonymous because we haven't logged in."""
selftest = self.make_proxy()
- self.assertEqual('Hello Anonymous.', selftest.hello())
+ self.assertEqual("Hello Anonymous.", selftest.hello())
def test_user_pass_authentication(self):
"""If we provide a username and password, hello() will
@@ -89,7 +88,7 @@ class TestXMLRPCSelfTest(TestCaseWithFactory):
with anonymous_logged_in():
self.assertIs(None, getUtility(ILaunchBag).user)
selftest = self.make_logged_in_proxy()
- self.assertEqual('Hello Sample Person.', selftest.hello())
+ self.assertEqual("Hello Sample Person.", selftest.hello())
def test_login_differences(self):
"""Even if we log in as Foo Bar here, the XMLRPC method will see Sample
@@ -98,6 +97,7 @@ class TestXMLRPCSelfTest(TestCaseWithFactory):
person = self.factory.makePerson()
with person_logged_in(person):
selftest = self.make_logged_in_proxy()
- self.assertEqual('Hello Sample Person.', selftest.hello())
- self.assertEqual(person.displayname,
- getUtility(ILaunchBag).user.displayname)
+ self.assertEqual("Hello Sample Person.", selftest.hello())
+ self.assertEqual(
+ person.displayname, getUtility(ILaunchBag).user.displayname
+ )