diff --git a/.gitattributes b/.gitattributes index f8c79e2ac4369c3572bbfa6ad35a54f6b8953ccd..75b2fda7be081058e26e465e55a87f64b7b16e5e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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/common.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_parser.py -text LCU/Maintenance/DBInterface/monitoringdb/tests/test_generic_stationtestdata.csv -text diff --git a/LCU/Maintenance/DBInterface/monitoringdb/tests/__init__.py b/LCU/Maintenance/DBInterface/monitoringdb/tests/__init__.py index a23cebb546df0dffde79ef4731888d2364a13007..c54420b6cdc7d12fff94d0c82beb9fb366380be4 100644 --- a/LCU/Maintenance/DBInterface/monitoringdb/tests/__init__.py +++ b/LCU/Maintenance/DBInterface/monitoringdb/tests/__init__.py @@ -1 +1 @@ -__all__ = ['t_stationtest_model_creation', 't_stationtest_parser'] \ No newline at end of file +__all__ = ['t_stationtest_model_creation', 't_stationtest_parser', 't_django_insert'] \ No newline at end of file diff --git a/LCU/Maintenance/DBInterface/monitoringdb/tests/t_django_insert.py b/LCU/Maintenance/DBInterface/monitoringdb/tests/t_django_insert.py new file mode 100644 index 0000000000000000000000000000000000000000..b0561c23646dffa62c10a32bf84072d4615f06cb --- /dev/null +++ b/LCU/Maintenance/DBInterface/monitoringdb/tests/t_django_insert.py @@ -0,0 +1,38 @@ +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 diff --git a/LCU/Maintenance/DBInterface/monitoringdb/tests/t_stationtest_model_creation.py b/LCU/Maintenance/DBInterface/monitoringdb/tests/t_stationtest_model_creation.py index e198e8af58306f4f3efc9f0e22a71b7b44378c21..ebb74d66956186c32dac7206347a3ed2ad5e2e2e 100644 --- a/LCU/Maintenance/DBInterface/monitoringdb/tests/t_stationtest_model_creation.py +++ b/LCU/Maintenance/DBInterface/monitoringdb/tests/t_stationtest_model_creation.py @@ -10,5 +10,6 @@ class TestStationTestModelCreation(unittest.TestCase): result = raw_parser.dict_from_raw_station_test(test) print(result) + if __name__ == '__main__': unittest.main() \ No newline at end of file diff --git a/LCU/Maintenance/DBInterface/monitoringdb/tests/t_stationtest_parser.py b/LCU/Maintenance/DBInterface/monitoringdb/tests/t_stationtest_parser.py index 039e4ae7009b2c84b9564d9aeecb30e954f35f73..0932b4634680837910a3b5fd5df2fd8c75754eec 100644 --- a/LCU/Maintenance/DBInterface/monitoringdb/tests/t_stationtest_parser.py +++ b/LCU/Maintenance/DBInterface/monitoringdb/tests/t_stationtest_parser.py @@ -2,9 +2,7 @@ import unittest from .common import * - class TestStationTestsParser(unittest.TestCase): - def test_element_error_details_parsing(self): preparsed_element_error = ['20180508', 'HBA', '044', 'E_FAIL', {'x1': '99.5 140 101.6 99.8 140 102.4'},