Skip to content

Commit

Permalink
Refs #79. Added support for session_uuid in ServiceQueryTests POST API.
Browse files Browse the repository at this point in the history
  • Loading branch information
SBriere committed Apr 8, 2022
1 parent b4bb89b commit 0566931
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from opentera.db.models.TeraTest import TeraTest
from opentera.db.models.TeraService import TeraService
from opentera.db.models.TeraTestType import TeraTestType
from opentera.db.models.TeraSession import TeraSession
from opentera.redis.RedisVars import RedisVars
from modules.DatabaseModule.DBManager import DBManager
from sqlalchemy import exc
Expand Down Expand Up @@ -136,9 +137,19 @@ def post(self):
return gettext('Missing id_test field'), 400

if test_info['id_test'] == 0:
if 'id_session' not in test_info:
if 'id_session' not in test_info and 'session_uuid' not in test_info:
return gettext('Unknown session'), 400

if 'session_uuid' in test_info and 'id_session' not in test_info:
# Get session id
target_session = TeraSession.get_session_by_uuid(test_info['session_uuid'])
if not target_session:
return gettext('Unknown session'), 400
test_info['id_session'] = target_session.id_session

if 'session_uuid' in test_info:
del test_info['session_uuid']

if 'id_test_type' not in test_info and 'test_type_uuid' not in test_info:
return gettext('Missing id_test_type field'), 400

Expand All @@ -163,7 +174,8 @@ def post(self):
else:
test_name = test_type.test_name
test_name += ' #' + \
str(TeraTest.count_with_filters({'id_session': test_info['id_session']}))
str(TeraTest.count_with_filters({'id_session': test_info['id_session'],
'id_test_type': test_info['id_test_type']})+1)
test_info['test_name'] = test_name

# Check if the service can create/update that test
Expand Down

0 comments on commit 0566931

Please sign in to comment.