Skip to content
Snippets Groups Projects
Commit 906eb84b authored by Mattia Mancini's avatar Mattia Mancini
Browse files

OSB-28: implemented first database tests

parent d73cd74f
No related branches found
No related tags found
2 merge requests!89Monitoring maintenance Epic branch merge,!1Resolve OSB-13 "Monitoringmaintenance "
...@@ -1826,6 +1826,7 @@ LCU/Maintenance/DBInterface/monitoringdb/station_test_raw_parser.py -text ...@@ -1826,6 +1826,7 @@ LCU/Maintenance/DBInterface/monitoringdb/station_test_raw_parser.py -text
LCU/Maintenance/DBInterface/monitoringdb/tests/__init__.py -text LCU/Maintenance/DBInterface/monitoringdb/tests/__init__.py -text
LCU/Maintenance/DBInterface/monitoringdb/tests/common.py -text LCU/Maintenance/DBInterface/monitoringdb/tests/common.py -text
LCU/Maintenance/DBInterface/monitoringdb/tests/old_tests.py -text LCU/Maintenance/DBInterface/monitoringdb/tests/old_tests.py -text
LCU/Maintenance/DBInterface/monitoringdb/tests/t_django_insert.py -text
LCU/Maintenance/DBInterface/monitoringdb/tests/t_stationtest_model_creation.py -text LCU/Maintenance/DBInterface/monitoringdb/tests/t_stationtest_model_creation.py -text
LCU/Maintenance/DBInterface/monitoringdb/tests/t_stationtest_parser.py -text LCU/Maintenance/DBInterface/monitoringdb/tests/t_stationtest_parser.py -text
LCU/Maintenance/DBInterface/monitoringdb/tests/test_generic_stationtestdata.csv -text LCU/Maintenance/DBInterface/monitoringdb/tests/test_generic_stationtestdata.csv -text
......
__all__ = ['t_stationtest_model_creation', 't_stationtest_parser'] __all__ = ['t_stationtest_model_creation', 't_stationtest_parser', 't_django_insert']
\ No newline at end of file \ No newline at end of file
from django.test import TestCase
import lofar.maintenance.django_postgresql.settings as settings
import lofar.maintenance.monitoringdb.serializers.component_error as component_error
from lofar.maintenance.monitoringdb.models.station import Station
from lofar.maintenance.monitoringdb.models.station_test import StationTest
from datetime import datetime
from lofar.maintenance.monitoringdb.models.component_error import ComponentError
class TestStationTestInsert(TestCase):
def test_insert_station_test_no_component_errors(self):
pass
class TestComponentErrorInsert(TestCase):
def test_insert_component_error_with_details(self):
station_entry = Station(location='Here', name='CS001C', type='C')
station_entry.save()
station_test_entry = StationTest(start_datetime=datetime(2017, 4, 12, 0,0,0),
end_datetime=datetime(2017, 4, 12, 1,0,0),
checks='Some checks',
station=station_entry
)
station_test_entry.save()
test_data = {'component': {'component_id': 50, 'type': 'LBL'}, 'details': {'xoff': '11', 'yoff': '25', 'xval': 77.0, 'yval': 75.9}, 'type': 'DOWN'}
component_error_entry = component_error.ComponentErrorSerializer.insert_component_error(station_test_entry,
station_entry,
test_data)
component_error_entry.save()
id = component_error_entry.pk
print(ComponentError.objects.get(pk=id).details)
\ No newline at end of file
...@@ -10,5 +10,6 @@ class TestStationTestModelCreation(unittest.TestCase): ...@@ -10,5 +10,6 @@ class TestStationTestModelCreation(unittest.TestCase):
result = raw_parser.dict_from_raw_station_test(test) result = raw_parser.dict_from_raw_station_test(test)
print(result) print(result)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
\ No newline at end of file
...@@ -2,9 +2,7 @@ import unittest ...@@ -2,9 +2,7 @@ import unittest
from .common import * from .common import *
class TestStationTestsParser(unittest.TestCase): class TestStationTestsParser(unittest.TestCase):
def test_element_error_details_parsing(self): def test_element_error_details_parsing(self):
preparsed_element_error = ['20180508', 'HBA', '044', 'E_FAIL', preparsed_element_error = ['20180508', 'HBA', '044', 'E_FAIL',
{'x1': '99.5 140 101.6 99.8 140 102.4'}, {'x1': '99.5 140 101.6 99.8 140 102.4'},
......
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