Skip to content
Snippets Groups Projects
Commit 4f81cb17 authored by Roy de Goei's avatar Roy de Goei
Browse files

TMSS-687: Review comment processed, testcase added

parent 95d7b972
No related branches found
No related tags found
1 merge request!399Resolve TMSS-687
...@@ -193,6 +193,34 @@ class TestPreCalculationService(unittest.TestCase): ...@@ -193,6 +193,34 @@ class TestPreCalculationService(unittest.TestCase):
st_objects = StationTimeline.objects.filter(timestamp=datetime.date.today()) st_objects = StationTimeline.objects.filter(timestamp=datetime.date.today())
self.assertEqual(len(st_objects), nbr_stations) self.assertEqual(len(st_objects), nbr_stations)
def test_all_stations_calculated_with_two_jobs_started(self):
"""
Test if starting two jobs of (pre)calculation service results in no Exception, there are no
duplicate data stored (covered by the Constraints in the model)
It will test the scheduler with interval of 20 seconds, to make sure one interval after the start has been passed
"""
# Import here otherwise you get
# "django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings."
from lofar.sas.tmss.tmss.tmssapp.conversions import get_all_stations
from lofar.sas.tmss.tmss.tmssapp.models.calculations import StationTimeline
nbr_stations = len(get_all_stations())
# Initially there should be no data
self.assertEqual(len(StationTimeline.objects.all()), 0)
# Now we are going to create and start the calculation service with an interval of 20 sec
# nbr days to calculate ahead is 1 and nbr days before today 0 -> so it start with 'today' and after ~20 seconds
# 'tomorrow' etc..
job = create_service_job_for_sunrise_and_sunset_calculations(20, 1, 0)
job2 = create_service_job_for_sunrise_and_sunset_calculations(20, 1, 0)
job.start()
job2.start()
time.sleep(22)
job.stop()
job2.stop()
# Check what have been created should only be today and tomorrow
st_objects = StationTimeline.objects.all()
self.assertGreaterEqual(len(st_objects), 2 * nbr_stations)
if __name__ == '__main__': 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