Commit 47b8d3c0 authored by Tom Niget's avatar Tom Niget

py2to3: fix various python2 test and types breakings

parent 52d6f7a5
...@@ -816,7 +816,7 @@ class RegistryClient(object): ...@@ -816,7 +816,7 @@ class RegistryClient(object):
kw = getcallargs(*args, **kw) kw = getcallargs(*args, **kw)
query = '/' + name query = '/' + name
if kw: if kw:
if any(type(v) is not str for v in kw.values()): if any(not isinstance(v, (str, bytes)) for v in kw.values()):
raise TypeError(kw) raise TypeError(kw)
query += '?' + urlencode(kw) query += '?' + urlencode(kw)
url = self._path + query url = self._path + query
......
...@@ -70,7 +70,7 @@ class TestRegistryClientInteract(unittest.TestCase): ...@@ -70,7 +70,7 @@ class TestRegistryClientInteract(unittest.TestCase):
self.fail("Request token failed, no token in database") self.fail("Request token failed, no token in database")
# token: tuple[unicode,] # token: tuple[unicode,]
token = str(token[0]) token = str(token[0])
self.assertEqual(client.isToken(token), "1") self.assertEqual(client.isToken(token).decode(), "1")
# request ca # request ca
ca = client.getCa() ca = client.getCa()
...@@ -78,7 +78,7 @@ class TestRegistryClientInteract(unittest.TestCase): ...@@ -78,7 +78,7 @@ class TestRegistryClientInteract(unittest.TestCase):
# request a cert and get cn # request a cert and get cn
key, csr = tools.generate_csr() key, csr = tools.generate_csr()
cert = client.requestCertificate(token, csr) cert = client.requestCertificate(token, csr)
self.assertEqual(client.isToken(token), '', "token should be deleted") self.assertEqual(client.isToken(token).decode(), '', "token should be deleted")
# creat x509.cert object # creat x509.cert object
def write_to_temp(text): def write_to_temp(text):
...@@ -97,18 +97,19 @@ class TestRegistryClientInteract(unittest.TestCase): ...@@ -97,18 +97,19 @@ class TestRegistryClientInteract(unittest.TestCase):
# verfiy cn and prefix # verfiy cn and prefix
prefix = client.cert.prefix prefix = client.cert.prefix
cn = client.getNodePrefix(email) cn = client.getNodePrefix(email).decode()
self.assertEqual(tools.prefix2cn(prefix), cn) self.assertEqual(tools.prefix2cn(prefix), cn)
# simulate the process in cache # simulate the process in cache
# just prove works # just prove works
net_config = client.getNetworkConfig(prefix) net_config = client.getNetworkConfig(prefix)
self.assertIsNotNone(net_config)
net_config = json.loads(zlib.decompress(net_config)) net_config = json.loads(zlib.decompress(net_config))
self.assertEqual(net_config[u'max_clients'], self.max_clients) self.assertEqual(net_config[u'max_clients'], self.max_clients)
# no re6stnet, empty result # no re6stnet, empty result
bootpeer = client.getBootstrapPeer(prefix) bootpeer = client.getBootstrapPeer(prefix)
self.assertEqual(bootpeer, "") self.assertEqual(bootpeer.decode(), "")
# server should not die # server should not die
self.assertIsNone(self.server.proc.poll()) self.assertIsNone(self.server.proc.poll())
......
...@@ -8,8 +8,7 @@ import logging ...@@ -8,8 +8,7 @@ import logging
import random import random
from pathlib import Path from pathlib import Path
import network_build from . import network_build, re6st_wrap
import re6st_wrap
PING_PATH = str(Path(__file__).parent.resolve() / "ping.py") PING_PATH = str(Path(__file__).parent.resolve() / "ping.py")
......
...@@ -177,7 +177,7 @@ class TestRegistryServer(unittest.TestCase): ...@@ -177,7 +177,7 @@ class TestRegistryServer(unittest.TestCase):
request.send_header.assert_any_call("Content-Length", str(len(result))) request.send_header.assert_any_call("Content-Length", str(len(result)))
request.send_header.assert_any_call( request.send_header.assert_any_call(
registry.HMAC_HEADER, registry.HMAC_HEADER,
base64.b64encode(hmac.HMAC(key, result, hashlib.sha1).digest())) base64.b64encode(hmac.HMAC(key, result, hashlib.sha1).digest()).decode("ascii"))
request.wfile.write.assert_called_once_with(result) request.wfile.write.assert_called_once_with(result)
# remove the create session \n # remove the create session \n
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment