Commit 5b2f7cd0 authored by Jérome Perrin's avatar Jérome Perrin

software/slaprunner/test: port the tests to python3

parent 9f0d8d75
...@@ -48,7 +48,6 @@ setup(name=name, ...@@ -48,7 +48,6 @@ setup(name=name,
'supervisor', 'supervisor',
'psutil', 'psutil',
'paramiko', 'paramiko',
'six',
'requests', 'requests',
], ],
zip_safe=True, zip_safe=True,
......
...@@ -35,12 +35,11 @@ import subprocess ...@@ -35,12 +35,11 @@ import subprocess
import json import json
import time import time
from six.moves.urllib.parse import urlparse from urllib.parse import urlparse
from six.moves.urllib.parse import quote from urllib.parse import quote
from six.moves.urllib.parse import urljoin from urllib.parse import urljoin
from six.moves.configparser import ConfigParser from configparser import ConfigParser
import requests import requests
import six
from slapos.recipe.librecipe import generateHashFromFiles from slapos.recipe.librecipe import generateHashFromFiles
from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass
...@@ -191,7 +190,7 @@ class SlaprunnerTestCase(SlapOSInstanceTestCase): ...@@ -191,7 +190,7 @@ class SlaprunnerTestCase(SlapOSInstanceTestCase):
takeover_password = parameter_dict["takeover-%s-password" % scope] takeover_password = parameter_dict["takeover-%s-password" % scope]
resp = requests.get( resp = requests.get(
"%s?password=%s" % (takeover_url, takeover_password), f"{takeover_url}?password={takeover_password}",
verify=True) verify=True)
self.assertEqual(requests.codes.ok, resp.status_code) self.assertEqual(requests.codes.ok, resp.status_code)
self.assertNotIn("Error", resp.text, self.assertNotIn("Error", resp.text,
...@@ -363,7 +362,7 @@ class TestSSH(SlaprunnerTestCase): ...@@ -363,7 +362,7 @@ class TestSSH(SlaprunnerTestCase):
self.assertTrue(fingerprint_from_url.startswith('ssh-rsa-'), fingerprint_from_url) self.assertTrue(fingerprint_from_url.startswith('ssh-rsa-'), fingerprint_from_url)
fingerprint_from_url = fingerprint_from_url[len('ssh-rsa-'):] fingerprint_from_url = fingerprint_from_url[len('ssh-rsa-'):]
class KeyPolicy(object): class KeyPolicy:
"""Accept server key and keep it in self.key for inspection """Accept server key and keep it in self.key for inspection
""" """
def missing_host_key(self, client, hostname, key): def missing_host_key(self, client, hostname, key):
...@@ -507,7 +506,7 @@ class TestResilientInstance(SlaprunnerTestCase): ...@@ -507,7 +506,7 @@ class TestResilientInstance(SlaprunnerTestCase):
# just check that keys returned on requested partition are for resilient # just check that keys returned on requested partition are for resilient
self.assertSetEqual( self.assertSetEqual(
set(self.computer_partition.getConnectionParameterDict().keys()), set(self.computer_partition.getConnectionParameterDict().keys()),
set([ {
'backend-url', 'backend-url',
'feed-url-runner-1-pull', 'feed-url-runner-1-pull',
'feed-url-runner-1-push', 'feed-url-runner-1-push',
...@@ -520,7 +519,7 @@ class TestResilientInstance(SlaprunnerTestCase): ...@@ -520,7 +519,7 @@ class TestResilientInstance(SlaprunnerTestCase):
'takeover-runner-1-password', 'takeover-runner-1-password',
'takeover-runner-1-url', 'takeover-runner-1-url',
'url', 'url',
'webdav-url'])) 'webdav-url'})
class TestResilientCustomFrontend(TestCustomFrontend): class TestResilientCustomFrontend(TestCustomFrontend):
instance_max_retry = 20 instance_max_retry = 20
...@@ -601,5 +600,5 @@ class TestResilientDummyInstance(SlaprunnerTestCase): ...@@ -601,5 +600,5 @@ class TestResilientDummyInstance(SlaprunnerTestCase):
self.assertTrue(result_after.startswith("Hello"), result_after) self.assertTrue(result_after.startswith("Hello"), result_after)
self.assertIn(result, result_after, self.assertIn(result, result_after,
"%s not in %s" % (result, result_after)) f"{result} not in {result_after}")
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