← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~pappacena/turnip:py3-launchpad-interaction into turnip:master

 

Thiago F. Pappacena has proposed merging ~pappacena/turnip:py3-launchpad-interaction into turnip:master.

Commit message:
Fixing binary/str data types on interactions with Launchpad

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pappacena/turnip/+git/turnip/+merge/394715
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~pappacena/turnip:py3-launchpad-interaction into turnip:master.
diff --git a/turnip/pack/git.py b/turnip/pack/git.py
index 854c385..fa706d1 100644
--- a/turnip/pack/git.py
+++ b/turnip/pack/git.py
@@ -576,7 +576,7 @@ class PackBackendProtocol(PackServerProtocol):
         :param pathname: Repository's translated path.
         :param auth_params: Authorization info.
         """
-        xmlrpc_endpoint = config.get("virtinfo_endpoint")
+        xmlrpc_endpoint = six.ensure_binary(config.get("virtinfo_endpoint"))
         xmlrpc_timeout = int(config.get("virtinfo_timeout"))
         proxy = xmlrpc.Proxy(xmlrpc_endpoint, allowNone=True)
         repo_path = six.ensure_str(compose_path(self.factory.root, pathname))
@@ -778,7 +778,7 @@ class PackVirtFactory(protocol.Factory):
                  virtinfo_timeout, reactor=None):
         self.backend_host = backend_host
         self.backend_port = backend_port
-        self.virtinfo_endpoint = virtinfo_endpoint
+        self.virtinfo_endpoint = six.ensure_binary(virtinfo_endpoint)
         self.virtinfo_timeout = virtinfo_timeout
         self.reactor = reactor or default_reactor
 
diff --git a/turnip/pack/hookrpc.py b/turnip/pack/hookrpc.py
index ec62672..83cbf91 100644
--- a/turnip/pack/hookrpc.py
+++ b/turnip/pack/hookrpc.py
@@ -23,6 +23,7 @@ from __future__ import (
 import base64
 import json
 
+import six
 from six.moves import xmlrpc_client
 from twisted.internet import (
     defer,
@@ -130,7 +131,7 @@ class HookRPCHandler(object):
         self.auth_params = {}
         self.ref_paths = {}
         self.ref_permissions = {}
-        self.virtinfo_url = virtinfo_url
+        self.virtinfo_url = six.ensure_binary(virtinfo_url)
         self.virtinfo_timeout = virtinfo_timeout
         self.reactor = reactor or default_reactor
 
@@ -171,7 +172,7 @@ class HookRPCHandler(object):
             try:
                 result = yield proxy.callRemote(
                     'checkRefPermissions',
-                    ref_path,
+                    six.ensure_str(ref_path),
                     [xmlrpc_client.Binary(path) for path in missing],
                     auth_params).addTimeout(
                         self.virtinfo_timeout, self.reactor)
@@ -230,7 +231,7 @@ class HookRPCHandler(object):
     @defer.inlineCallbacks
     def notify(self, path):
         proxy = xmlrpc.Proxy(self.virtinfo_url, allowNone=True)
-        yield proxy.callRemote('notify', path).addTimeout(
+        yield proxy.callRemote('notify', six.ensure_str(path)).addTimeout(
             self.virtinfo_timeout, self.reactor)
 
     @defer.inlineCallbacks
diff --git a/turnip/pack/tests/test_functional.py b/turnip/pack/tests/test_functional.py
index dedaeb5..e74e47f 100644
--- a/turnip/pack/tests/test_functional.py
+++ b/turnip/pack/tests/test_functional.py
@@ -731,7 +731,8 @@ class FrontendFunctionalTestMixin(FunctionalTestMixin):
         yield self.assertCommandSuccess(
             (b'git', b'push', b'origin', b'master'), path=clone1)
         self.assertEqual(
-            [self.internal_name], self.virtinfo.push_notifications)
+            [six.ensure_text(self.internal_name)],
+            self.virtinfo.push_notifications)
 
     @defer.inlineCallbacks
     def test_unicode_fault(self):
@@ -848,7 +849,8 @@ class TestSmartHTTPFrontendFunctional(FrontendFunctionalTestMixin, TestCase):
         head_target = yield self.get_symbolic_ref(repo, b'HEAD')
         self.assertEqual(b'refs/heads/new-head', head_target)
         self.assertEqual(
-            [self.internal_name], self.virtinfo.push_notifications)
+            [six.ensure_text(self.internal_name)],
+            self.virtinfo.push_notifications)
 
     @defer.inlineCallbacks
     def test_turnip_set_symbolic_ref_error(self):
@@ -916,7 +918,7 @@ class TestSmartHTTPFrontendWithAuthFunctional(TestSmartHTTPFrontendFunctional):
             (b'git', b'push', b'origin', b'master'), path=clone)
         self.assertThat(self.virtinfo.ref_permissions_checks, MatchesListwise([
             MatchesListwise([
-                Equals(self.internal_name),
+                Equals(six.ensure_text(self.internal_name)),
                 Equals([b'refs/heads/master']),
                 MatchesDict({
                     'can-authenticate': Is(True),
diff --git a/turnip/pack/tests/test_hooks.py b/turnip/pack/tests/test_hooks.py
index bef4aae..eb2a37c 100644
--- a/turnip/pack/tests/test_hooks.py
+++ b/turnip/pack/tests/test_hooks.py
@@ -57,7 +57,7 @@ class HookProcessProtocol(protocol.ProcessProtocol):
 class MockHookRPCHandler(hookrpc.HookRPCHandler):
 
     def __init__(self):
-        super(MockHookRPCHandler, self).__init__(None, 15)
+        super(MockHookRPCHandler, self).__init__(b'http://localhost', 15)
         self.notifications = []
         self.ref_permissions = {}