Commit b5802865 authored by Tom Niget's avatar Tom Niget

Merge branch 'zdimension/re6st-py3-test' of...

Merge branch 'zdimension/re6st-py3-test' of https://lab.nexedi.com/nexedi/re6stnet into zdimension/re6st-py3-test
parents d8594f79 1a85418a
......@@ -35,13 +35,11 @@ RENEW_PERIOD = 30 * 86400
BABEL_HMAC = 'babel_hmac0', 'babel_hmac1', 'babel_hmac2'
def rpc(f):
args, varargs, varkw, defaults = inspect.getargspec(f)
assert not (varargs or varkw), f
if not defaults:
defaults = ()
i = len(args) - len(defaults)
f.getcallargs = eval("lambda %s: locals()" % ','.join(args[1:i]
+ list(map("%s=%r".__mod__, list(zip(args[i:], defaults))))))
argspec = inspect.getfullargspec(f)
assert not (argspec.varargs or argspec.varkw), f
sig = inspect.signature(f)
sig = sig.replace(parameters=[*sig.parameters.values()][1:])
f.getcallargs = eval("lambda %s: locals()" % str(sig)[1:-1])
return f
def rpc_private(f):
......@@ -818,7 +816,7 @@ class RegistryClient(object):
kw = getcallargs(*args, **kw)
query = '/' + name
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)
query += '?' + urlencode(kw)
url = self._path + query
......
......@@ -70,7 +70,7 @@ class TestRegistryClientInteract(unittest.TestCase):
self.fail("Request token failed, no token in database")
# token: tuple[unicode,]
token = str(token[0])
self.assertEqual(client.isToken(token), "1")
self.assertEqual(client.isToken(token).decode(), "1")
# request ca
ca = client.getCa()
......@@ -78,7 +78,7 @@ class TestRegistryClientInteract(unittest.TestCase):
# request a cert and get cn
key, csr = tools.generate_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
def write_to_temp(text):
......@@ -97,18 +97,19 @@ class TestRegistryClientInteract(unittest.TestCase):
# verfiy cn and prefix
prefix = client.cert.prefix
cn = client.getNodePrefix(email)
cn = client.getNodePrefix(email).decode()
self.assertEqual(tools.prefix2cn(prefix), cn)
# simulate the process in cache
# just prove works
net_config = client.getNetworkConfig(prefix)
self.assertIsNotNone(net_config)
net_config = json.loads(zlib.decompress(net_config))
self.assertEqual(net_config[u'max_clients'], self.max_clients)
# no re6stnet, empty result
bootpeer = client.getBootstrapPeer(prefix)
self.assertEqual(bootpeer, "")
self.assertEqual(bootpeer.decode(), "")
# server should not die
self.assertIsNone(self.server.proc.poll())
......
......@@ -8,8 +8,7 @@ import logging
import random
from pathlib import Path
import network_build
import re6st_wrap
from re6st.tests.test_network import network_build, re6st_wrap
PING_PATH = str(Path(__file__).parent.resolve() / "ping.py")
......
......@@ -15,10 +15,10 @@ def copy_file(self, infile, outfile, *args, **kw):
if infile == version["__file__"]:
if not self.dry_run:
log.info("generating %s -> %s", infile, outfile)
with open(outfile, "w", encoding="utf-8") as f:
with open(outfile, "wb") as f:
for x in sorted(version.items()):
if not x[0].startswith("_"):
f.write("%s = %r\n" % x)
f.write(("%s = %r\n" % x).encode())
return outfile, 1
elif isinstance(self, build_py) and \
os.stat(infile).st_mode & stat.S_IEXEC:
......@@ -27,14 +27,17 @@ def copy_file(self, infile, outfile, *args, **kw):
# Adjust interpreter of OpenVPN hooks.
with open(infile) as src:
first_line = src.readline()
m = first_line_re.match(first_line)
m = first_line_re.match(first_line.encode())
if m and not self.dry_run:
log.info("copying and adjusting %s -> %s", infile, outfile)
executable = self.distribution.command_obj['build'].executable
patched = "#!%s%s\n" % (executable, m.group(1) or '')
patched += src.read()
with open(outfile, "w") as dst:
dst.write(patched)
dst = os.open(outfile, os.O_CREAT | os.O_WRONLY | os.O_TRUNC)
try:
os.write(dst, patched.encode())
finally:
os.close(dst)
return outfile, 1
cls, = self.__class__.__bases__
return cls.copy_file(self, infile, outfile, *args, **kw)
......
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