Skip to content
Snippets Groups Projects
Commit fd768cf1 authored by Jörn Künsemöller's avatar Jörn Künsemöller
Browse files

TMSS-1996: full test setup

parent efd07733
No related branches found
No related tags found
1 merge request!1163Resolve TMSS-1996
......@@ -47,8 +47,6 @@ class TestReportRefreshService(unittest.TestCase):
cls.tmss_test_env = TMSSTestEnvironment(exchange=cls.tmp_exchange.address, populate_test_data=False, populate_schemas=False, start_websocket=False, start_postgres_listener=True, enable_viewflow=False)
cls.tmss_test_env.start()
cls.test_data_creator = cls.tmss_test_env.create_test_data_creator()
@classmethod
def tearDownClass(cls) -> None:
cls.tmss_test_env.stop()
......@@ -60,12 +58,33 @@ class TestReportRefreshService(unittest.TestCase):
of a cycle report in the database.
'''
# test data setup
from lofar.sas.tmss.test import tmss_test_data_django_models
from lofar.sas.tmss.tmss.tmssapp import models
project = models.Project.objects.create(**tmss_test_data_django_models.Project_test_data(name=str(uuid.uuid4())))
cycle = models.Cycle.objects.create(**tmss_test_data_django_models.Cycle_test_data(name=str(uuid.uuid4())))
project.cycles.set([cycle])
project.save()
scheduling_set = models.SchedulingSet.objects.create(**tmss_test_data_django_models.SchedulingSet_test_data(project=project))
scheduling_unit_template = models.SchedulingUnitTemplate.get_latest(name='scheduling unit')
scheduling_unit_draft = models.SchedulingUnitDraft.objects.create(**tmss_test_data_django_models.SchedulingUnitDraft_test_data(name=str(uuid.uuid4()), template=scheduling_unit_template, scheduling_set=scheduling_set))
obs_task_template = models.TaskTemplate.get_latest(name='target observation')
task_draft = models.TaskDraft.objects.create(**tmss_test_data_django_models.TaskDraft_test_data(name=str(uuid.uuid4()), specifications_template=obs_task_template, scheduling_unit_draft=scheduling_unit_draft))
task_blueprint = models.TaskBlueprint.objects.create(**tmss_test_data_django_models.TaskBlueprint_test_data(name=str(uuid.uuid4()), task_draft=task_draft))
subtask_obs = models.Subtask.objects.create(**tmss_test_data_django_models.Subtask_test_data(state=models.SubtaskState.objects.get(value="defining"),
subtask_template=models.SubtaskTemplate.get_latest(name='observation control'),
task_blueprint=task_blueprint))
subtask_obs.state = models.SubtaskState.objects.get(value="defined")
subtask_obs.save()
# create and start the service (the object under test)
service = create_service(exchange=self.tmp_exchange.address)
with BusListenerJanitor(service):
pass
# todo
self.assertEqual(models.CycleReport.objects.filter(cycle=cycle).count(), 0)
subtask_obs.state = models.SubtaskState.objects.get(value="defined")
subtask_obs.save()
time.sleep(5) # todo: ugly, is there a better way?
self.assertEqual(models.CycleReport.objects.filter(cycle=cycle).count(), 1)
if __name__ == '__main__':
......
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