Skip to content
Snippets Groups Projects
Commit 4ee5d2ab authored by goei's avatar goei
Browse files

TMSS-281: Add simple sip generate test in t_adapter (and rename t_parset_adapter to t_adapter)

parent 71658e41
No related branches found
No related tags found
1 merge request!195Resolve TMSS-281
......@@ -29,7 +29,7 @@ if(BUILD_TESTING)
lofar_add_test(t_tmssapp_specification_permissions)
lofar_add_test(t_tmss_session_auth)
lofar_add_test(t_subtasks)
lofar_add_test(t_parset_adapter)
lofar_add_test(t_adapter)
lofar_add_test(t_tasks)
lofar_add_test(t_scheduling)
......
......@@ -41,6 +41,8 @@ rest_data_creator = TMSSRESTTestDataCreator(BASE_URL, AUTH)
from lofar.sas.tmss.tmss.tmssapp import models
from lofar.sas.tmss.tmss.tmssapp.adapters.parset import convert_to_parset
from lofar.common.json_utils import get_default_json_object_for_schema
from lofar.sas.tmss.tmss.tmssapp.adapters.sip import generate_sip_for_dataproduct
class ParsetAdapterTest(unittest.TestCase):
def test_01(self):
......@@ -55,6 +57,23 @@ class ParsetAdapterTest(unittest.TestCase):
parset = convert_to_parset(subtask)
class SIPdapterTest(unittest.TestCase):
def test_simple_sip_generate_from_dataproduct(self):
subtask_template = models.SubtaskTemplate.objects.get(name='observationcontrol schema')
specifications_doc = get_default_json_object_for_schema(subtask_template.schema)
for dp in specifications_doc['stations']['digital_pointings']:
dp['subbands'] = list(range(8))
subtask_data = Subtask_test_data(subtask_template=subtask_template, specifications_doc=specifications_doc)
subtask:models.Subtask = models.Subtask.objects.create(**subtask_data)
subtask_output = models.SubtaskOutput.objects.create(**SubtaskOutput_test_data(subtask=subtask))
dataproduct:models.Dataproduct = models.Dataproduct.objects.create(**Dataproduct_test_data(producer=subtask_output))
sip = generate_sip_for_dataproduct(dataproduct)
# TODO: Although validate succeed at this step, would be interesting to check some xml values
# print(sip.get_prettyxml())
if __name__ == "__main__":
os.environ['TZ'] = 'UTC'
unittest.main()
......@@ -2,5 +2,5 @@
# Run the unit test
source python-coverage.sh
python_coverage_test "*tmss*" t_parset_adapter.py
python_coverage_test "*tmss*" t_adapter.py
#!/bin/sh
./runctest.sh t_adapter
\ No newline at end of file
#!/bin/sh
./runctest.sh t_parset_adapter
\ No newline at end of file
......@@ -326,11 +326,12 @@ def Subtask_test_data(task_blueprint: models.TaskBlueprint=None, subtask_templat
if specifications_doc is None:
specifications_doc = get_default_json_object_for_schema(subtask_template.schema)
# Type need to be a datetime object not a str so do not add .isoformat()
if start_time is None:
start_time = datetime.utcnow().isoformat()
start_time = datetime.utcnow()
if stop_time is None:
stop_time = datetime.utcnow().isoformat()
stop_time = datetime.utcnow()
if cluster is None:
cluster = models.Cluster.objects.create(name="dummy cluster", location="downstairs", tags=[])
......@@ -345,7 +346,7 @@ def Subtask_test_data(task_blueprint: models.TaskBlueprint=None, subtask_templat
"task_blueprint": task_blueprint,
"specifications_template": subtask_template,
"tags": ["TMSS", "TESTING"],
"do_cancel": datetime.utcnow().isoformat(),
"do_cancel": datetime.utcnow(),
"priority": 1,
"schedule_method": models.ScheduleMethod.objects.get(value='manual'),
"cluster": cluster}
......
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