Fix system tests

This commit is contained in:
Lorenzo Bolla
2021-09-21 18:52:43 +02:00
parent ff51c46915
commit 787cc8e3ee
51 changed files with 607 additions and 66 deletions

View File

@@ -78,11 +78,31 @@ class GPGFinder(object):
return None
class DotFinder(object):
"""
dot binary discovery.
"""
def __init__(self):
self.dot = self.find_dot(["dot"])
def find_dot(self, executables):
for executable in executables:
try:
subprocess.check_output([executable])
return executable
except Exception:
pass
return None
class BaseTest(object):
"""
Base class for all tests.
"""
skipTest = False
longTest = False
fixturePool = False
fixturePoolCopy = False
@@ -92,6 +112,7 @@ class BaseTest(object):
requiresFTP = False
requiresGPG1 = False
requiresGPG2 = False
requiresDot = False
expectedCode = 0
configFile = {
@@ -128,11 +149,15 @@ class BaseTest(object):
captureResults = False
gpgFinder = GPGFinder()
dotFinder = DotFinder()
def test(self):
self.prepare()
self.run()
self.check()
try:
self.run()
self.check()
finally:
self.teardown()
def prepare_remove_all(self):
if os.path.exists(os.path.join(os.environ["HOME"], ".aptly")):
@@ -165,6 +190,8 @@ class BaseTest(object):
return False
if self.requiresGPG2 and self.gpgFinder.gpg2 is None:
return False
if self.requiresDot and self.dotFinder.dot is None:
return False
return True
@@ -368,6 +395,9 @@ class BaseTest(object):
self.prepare_default_config()
self.prepare_fixture()
def teardown(self):
pass
def start_webserver(self, directory):
FileHTTPServerRequestHandler.rootPath = directory
self.webserver = ThreadedTCPServer(