← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-webserviceresponsewrapper-jsonbody into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-webserviceresponsewrapper-jsonbody into launchpad:master.

Commit message:
Fix JSON decoding of WebServiceResponseWrapper.body

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/396113

We have a jsonBody() method, so use it.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-webserviceresponsewrapper-jsonbody into launchpad:master.
diff --git a/lib/lp/code/model/tests/test_gitref.py b/lib/lp/code/model/tests/test_gitref.py
index ba9e25f..715bbb5 100644
--- a/lib/lp/code/model/tests/test_gitref.py
+++ b/lib/lp/code/model/tests/test_gitref.py
@@ -867,7 +867,7 @@ class TestGitRefWebservice(TestCaseWithFactory):
             ref.owner, permission=OAuthPermission.WRITE_PUBLIC)
         webservice.default_api_version = "devel"
         response = webservice.named_get(ref_url, "getGrants")
-        self.assertThat(json.loads(response.body), MatchesSetwise(
+        self.assertThat(response.jsonBody(), MatchesSetwise(
             MatchesDict({
                 "grantee_type": Equals("Repository owner"),
                 "grantee_link": Is(None),
@@ -951,10 +951,10 @@ class TestGitRefWebservice(TestCaseWithFactory):
         webservice.default_api_version = "devel"
         response = webservice.named_get(
             ref_url, "checkPermissions", person=owner_url)
-        self.assertEqual(["create", "push"], json.loads(response.body))
+        self.assertEqual(["create", "push"], response.jsonBody())
         response = webservice.named_get(
             ref_url, "checkPermissions", person=grantee_urls[0])
-        self.assertEqual(["create"], json.loads(response.body))
+        self.assertEqual(["create"], response.jsonBody())
         response = webservice.named_get(
             ref_url, "checkPermissions", person=grantee_urls[1])
-        self.assertEqual(["push", "force-push"], json.loads(response.body))
+        self.assertEqual(["push", "force-push"], response.jsonBody())
diff --git a/lib/lp/code/model/tests/test_gitrepository.py b/lib/lp/code/model/tests/test_gitrepository.py
index 5edbcf7..1e12199 100644
--- a/lib/lp/code/model/tests/test_gitrepository.py
+++ b/lib/lp/code/model/tests/test_gitrepository.py
@@ -4325,7 +4325,7 @@ class TestGitRepositoryWebservice(TestCaseWithFactory):
             repository.owner, permission=OAuthPermission.WRITE_PUBLIC)
         webservice.default_api_version = "devel"
         response = webservice.named_get(repository_url, "getRules")
-        self.assertThat(json.loads(response.body), MatchesListwise([
+        self.assertThat(response.jsonBody(), MatchesListwise([
             MatchesDict({
                 "ref_pattern": Equals("refs/heads/stable/*"),
                 "grants": MatchesSetwise(
@@ -4440,7 +4440,7 @@ class TestGitRepositoryWebservice(TestCaseWithFactory):
         response = webservice.named_get(
             repository_url, "checkRefPermissions", person=owner_url,
             paths=["refs/heads/master", "refs/heads/next", "refs/other"])
-        self.assertThat(json.loads(response.body), MatchesDict({
+        self.assertThat(response.jsonBody(), MatchesDict({
             "refs/heads/master": Equals(["create", "push"]),
             "refs/heads/next": Equals(["create", "push"]),
             "refs/other": Equals(["create", "push", "force-push"]),
@@ -4448,7 +4448,7 @@ class TestGitRepositoryWebservice(TestCaseWithFactory):
         response = webservice.named_get(
             repository_url, "checkRefPermissions", person=grantee_urls[0],
             paths=["refs/heads/master", "refs/heads/next", "refs/other"])
-        self.assertThat(json.loads(response.body), MatchesDict({
+        self.assertThat(response.jsonBody(), MatchesDict({
             "refs/heads/master": Equals(["create"]),
             "refs/heads/next": Equals([]),
             "refs/other": Equals([]),
@@ -4456,7 +4456,7 @@ class TestGitRepositoryWebservice(TestCaseWithFactory):
         response = webservice.named_get(
             repository_url, "checkRefPermissions", person=grantee_urls[1],
             paths=["refs/heads/master", "refs/heads/next", "refs/other"])
-        self.assertThat(json.loads(response.body), MatchesDict({
+        self.assertThat(response.jsonBody(), MatchesDict({
             "refs/heads/master": Equals(["push"]),
             "refs/heads/next": Equals(["push", "force-push"]),
             "refs/other": Equals([]),
@@ -4477,7 +4477,7 @@ class TestGitRepositoryWebservice(TestCaseWithFactory):
         webservice.default_api_version = "devel"
         response = webservice.named_post(repository_url, "issueAccessToken")
         self.assertEqual(200, response.status)
-        macaroon = Macaroon.deserialize(json.loads(response.body))
+        macaroon = Macaroon.deserialize(response.jsonBody())
         with person_logged_in(ANONYMOUS):
             self.assertThat(macaroon, MatchesStructure(
                 location=Equals(config.vhost.mainsite.hostname),