launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25982
[Merge] ~cjwatson/launchpad:py3-requestProxyToken-tests into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-requestProxyToken-tests into launchpad:master.
Commit message:
Fix requestProxyToken tests for Python 3
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/396108
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-requestProxyToken-tests into launchpad:master.
diff --git a/lib/lp/buildmaster/tests/snapbuildproxy.py b/lib/lp/buildmaster/tests/snapbuildproxy.py
index fc8893a..a1e2271 100644
--- a/lib/lp/buildmaster/tests/snapbuildproxy.py
+++ b/lib/lp/buildmaster/tests/snapbuildproxy.py
@@ -43,14 +43,14 @@ class ProxyAuthAPITokensResource(resource.Resource):
self.requests = []
def render_POST(self, request):
- content = request.content.read()
+ content = json.loads(request.content.read().decode("UTF-8"))
self.requests.append({
"method": request.method,
"uri": request.uri,
"headers": dict(request.requestHeaders.getAllRawHeaders()),
- "content": content,
+ "json": content,
})
- username = json.loads(content)["username"]
+ username = content["username"]
return json.dumps({
"username": username,
"secret": uuid.uuid4().hex,
diff --git a/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py b/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py
index d33841b..e5d38a5 100644
--- a/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py
+++ b/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py
@@ -22,7 +22,6 @@ import pytz
from six.moves.urllib_parse import urlsplit
from testtools import ExpectedException
from testtools.matchers import (
- AfterPreprocessing,
ContainsDict,
Equals,
Is,
@@ -231,11 +230,12 @@ class TestAsyncOCIRecipeBuildBehaviour(
[ref] = self.factory.makeGitRefs()
job = self.makeJob(git_ref=ref)
yield job.extraBuildArgs()
+ expected_uri = urlsplit(
+ config.snappy.builder_proxy_auth_api_endpoint).path.encode("UTF-8")
self.assertThat(self.proxy_api.tokens.requests, MatchesListwise([
MatchesDict({
- "method": Equals("POST"),
- "uri": Equals(urlsplit(
- config.snappy.builder_proxy_auth_api_endpoint).path),
+ "method": Equals(b"POST"),
+ "uri": Equals(expected_uri),
"headers": ContainsDict({
b"Authorization": MatchesListwise([
Equals(b"Basic " + base64.b64encode(
@@ -244,9 +244,9 @@ class TestAsyncOCIRecipeBuildBehaviour(
Equals(b"application/json"),
]),
}),
- "content": AfterPreprocessing(json.loads, MatchesDict({
+ "json": MatchesDict({
"username": StartsWith(job.build.build_cookie + "-"),
- })),
+ }),
}),
]))
diff --git a/lib/lp/snappy/tests/test_snapbuildbehaviour.py b/lib/lp/snappy/tests/test_snapbuildbehaviour.py
index 6cbfb9a..54af8f3 100644
--- a/lib/lp/snappy/tests/test_snapbuildbehaviour.py
+++ b/lib/lp/snappy/tests/test_snapbuildbehaviour.py
@@ -9,7 +9,6 @@ __metaclass__ = type
import base64
from datetime import datetime
-import json
import os.path
from textwrap import dedent
import time
@@ -349,11 +348,12 @@ class TestAsyncSnapBuildBehaviour(StatsMixin, TestSnapBuildBehaviourBase):
branch = self.factory.makeBranch()
job = self.makeJob(branch=branch)
yield job.extraBuildArgs()
+ expected_uri = urlsplit(
+ config.snappy.builder_proxy_auth_api_endpoint).path.encode("UTF-8")
self.assertThat(self.proxy_api.tokens.requests, MatchesListwise([
MatchesDict({
- "method": Equals("POST"),
- "uri": Equals(urlsplit(
- config.snappy.builder_proxy_auth_api_endpoint).path),
+ "method": Equals(b"POST"),
+ "uri": Equals(expected_uri),
"headers": ContainsDict({
b"Authorization": MatchesListwise([
Equals(b"Basic " + base64.b64encode(
@@ -362,9 +362,9 @@ class TestAsyncSnapBuildBehaviour(StatsMixin, TestSnapBuildBehaviourBase):
Equals(b"application/json"),
]),
}),
- "content": AfterPreprocessing(json.loads, MatchesDict({
+ "json": MatchesDict({
"username": StartsWith(job.build.build_cookie + "-"),
- })),
+ }),
}),
]))