Skip to content
Snippets Groups Projects
Commit 8981f320 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-142: added cmdline option to provide preffered django port

parent cb62be35
No related branches found
No related tags found
2 merge requests!98Resolve TMSS-142 and TMSS-141,!97Resolve TMSS-138
......@@ -230,12 +230,12 @@ class TMSSDjangoServerInstance():
class TMSSTestEnvironment:
'''Create and run a test django TMSS server against a newly created test database and a test ldap server (and cleanup automagically)'''
def __init__(self):
def __init__(self, preferred_django_port: int=8000):
self.ldap_server = TestLDAPServer(user='test', password='test')
self.database = TMSSTestDatabaseInstance()
self.django_server = TMSSDjangoServerInstance(db_dbcreds_id=self.database.dbcreds_id,
ldap_dbcreds_id=self.ldap_server.dbcreds_id,
port=find_free_port(8000))
port=find_free_port(preferred_django_port))
def start(self):
self.ldap_server.start()
......@@ -288,10 +288,18 @@ def main_test_database():
def main_test_environment():
"""instantiate, run and destroy a full tmss test environment (postgress database, ldap server, django server)"""
from optparse import OptionParser
os.environ['TZ'] = 'UTC'
parser = OptionParser('%prog [options]',
description='setup/run/teardown a full TMSS test environment including a fresh and isolated database, LDAP server and DJANGO REST server.')
parser.add_option("-p", "--port", dest="port", type="int", default=find_free_port(8000),
help="try to use this port for the DJANGO REST API. If not available, then a random free port is used and logged. [default=%default]")
(options, args) = parser.parse_args()
logging.basicConfig(format = '%(asctime)s %(levelname)s %(message)s', level = logging.INFO)
with TMSSTestEnvironment() as instance:
with TMSSTestEnvironment(preferred_django_port=options.port) as instance:
# print some nice info for the user to use the test servers...
# use print instead of log for clean lines.
for h in logging.root.handlers:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment