Commit 2e5bfa9a authored by Jérome Perrin's avatar Jérome Perrin

software/erp5_upgrade/test: port the tests to python3

parent 5b2f7cd0
...@@ -44,7 +44,6 @@ setup(name=name, ...@@ -44,7 +44,6 @@ setup(name=name,
'slapos.core', 'slapos.core',
'supervisor', 'supervisor',
'slapos.libnetworkcache', 'slapos.libnetworkcache',
'typing; python_version<"3"',
], ],
test_suite='test', test_suite='test',
) )
...@@ -35,8 +35,8 @@ import tempfile ...@@ -35,8 +35,8 @@ import tempfile
import time import time
import requests import requests
import six.moves.urllib as urllib import urllib.parse
import six.moves.xmlrpc_client import xmlrpc.client
import urllib3 import urllib3
from slapos.grid.utils import md5digest from slapos.grid.utils import md5digest
...@@ -83,8 +83,8 @@ class ERP5UpgradeTestCase(SlapOSInstanceTestCase): ...@@ -83,8 +83,8 @@ class ERP5UpgradeTestCase(SlapOSInstanceTestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
# request and instanciate with old software url # request and instantiate with old software url
super(ERP5UpgradeTestCase, cls).setUpClass() super().setUpClass()
cls.setUpOldInstance() cls.setUpOldInstance()
...@@ -155,7 +155,7 @@ class TestERP5Upgrade(ERP5UpgradeTestCase): ...@@ -155,7 +155,7 @@ class TestERP5Upgrade(ERP5UpgradeTestCase):
# wait for old site creation # wait for old site creation
cls.session.get( cls.session.get(
'{zope_base_url}/person_module'.format(zope_base_url=cls.zope_base_url), f'{cls.zope_base_url}/person_module',
auth=requests.auth.HTTPBasicAuth( auth=requests.auth.HTTPBasicAuth(
username=param_dict['inituser-login'], username=param_dict['inituser-login'],
password=param_dict['inituser-password'], password=param_dict['inituser-password'],
...@@ -171,16 +171,12 @@ class TestERP5Upgrade(ERP5UpgradeTestCase): ...@@ -171,16 +171,12 @@ class TestERP5Upgrade(ERP5UpgradeTestCase):
ssl_context = ssl.create_default_context() ssl_context = ssl.create_default_context()
ssl_context.check_hostname = False ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE ssl_context.verify_mode = ssl.CERT_NONE
erp5_xmlrpc_client = six.moves.xmlrpc_client.ServerProxy( erp5_xmlrpc_client = xmlrpc.client.ServerProxy(
cls.authenticated_zope_base_url, cls.authenticated_zope_base_url,
context=ssl_context, context=ssl_context,
) )
# BBB use as a context manager only on python3 with erp5_xmlrpc_client:
if sys.version_info < (3, ):
yield erp5_xmlrpc_client yield erp5_xmlrpc_client
else:
with erp5_xmlrpc_client:
yield erp5_xmlrpc_client
def addPythonScript(script_id, params, body): def addPythonScript(script_id, params, body):
with getXMLRPCClient() as erp5_xmlrpc_client: with getXMLRPCClient() as erp5_xmlrpc_client:
...@@ -188,7 +184,7 @@ class TestERP5Upgrade(ERP5UpgradeTestCase): ...@@ -188,7 +184,7 @@ class TestERP5Upgrade(ERP5UpgradeTestCase):
try: try:
custom.manage_addProduct.PythonScripts.manage_addPythonScript( custom.manage_addProduct.PythonScripts.manage_addPythonScript(
script_id) script_id)
except six.moves.xmlrpc_client.ProtocolError as e: except xmlrpc.client.ProtocolError as e:
if e.errcode != 302: if e.errcode != 302:
raise raise
getattr(custom, script_id).ZPythonScriptHTML_editAction( getattr(custom, script_id).ZPythonScriptHTML_editAction(
......
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