Tests: refactored prerequisites model.
This commit is contained in:
@@ -4,6 +4,19 @@ from unit.applications.proto import TestApplicationProto
|
||||
|
||||
|
||||
class TestApplicationGo(TestApplicationProto):
|
||||
@classmethod
|
||||
def setUpClass(cls, complete_check=True):
|
||||
unit = super().setUpClass(complete_check=False)
|
||||
|
||||
# check go module
|
||||
|
||||
go_app = TestApplicationGo()
|
||||
go_app.testdir = unit.testdir
|
||||
if go_app.prepare_env('empty', 'app').returncode == 0:
|
||||
cls.available['modules']['go'] = []
|
||||
|
||||
return unit if not complete_check else unit.complete()
|
||||
|
||||
def prepare_env(self, script, name):
|
||||
if not os.path.exists(self.testdir + '/go'):
|
||||
os.mkdir(self.testdir + '/go')
|
||||
|
||||
@@ -4,6 +4,17 @@ from unit.applications.proto import TestApplicationProto
|
||||
|
||||
|
||||
class TestApplicationNode(TestApplicationProto):
|
||||
@classmethod
|
||||
def setUpClass(cls, complete_check=True):
|
||||
unit = super().setUpClass(complete_check=False)
|
||||
|
||||
# check node module
|
||||
|
||||
if os.path.exists(unit.pardir + '/node/node_modules'):
|
||||
cls.available['modules']['node'] = []
|
||||
|
||||
return unit if not complete_check else unit.complete()
|
||||
|
||||
def load(self, script, name='app.js'):
|
||||
# copy application
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import re
|
||||
import ssl
|
||||
import subprocess
|
||||
from unit.applications.proto import TestApplicationProto
|
||||
@@ -12,6 +13,27 @@ class TestApplicationTLS(TestApplicationProto):
|
||||
self.context.check_hostname = False
|
||||
self.context.verify_mode = ssl.CERT_NONE
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls, complete_check=True):
|
||||
unit = super().setUpClass(complete_check=False)
|
||||
|
||||
# check tls module
|
||||
|
||||
try:
|
||||
subprocess.check_output(['which', 'openssl'])
|
||||
|
||||
output = subprocess.check_output(
|
||||
[unit.unitd, '--version'], stderr=subprocess.STDOUT
|
||||
)
|
||||
|
||||
if re.search('--openssl', output.decode()):
|
||||
cls.available['modules']['openssl'] = []
|
||||
|
||||
except:
|
||||
pass
|
||||
|
||||
return unit if not complete_check else unit.complete()
|
||||
|
||||
def certificate(self, name='default', load=True):
|
||||
self.openssl_conf()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user