diff --git a/SAS/TMSS/src/tmss/tmssapp/adapters/feedback.py b/SAS/TMSS/src/tmss/tmssapp/adapters/feedback.py index f87dd3ff615c89e037a7c0bb617f25853c7b23c4..0963e622856fde662f5d66f3d361f6f63121fd1a 100644 --- a/SAS/TMSS/src/tmss/tmssapp/adapters/feedback.py +++ b/SAS/TMSS/src/tmss/tmssapp/adapters/feedback.py @@ -17,6 +17,7 @@ # You should have received a copy of the GNU General Public License along # with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. +from dateutil import parser from lofar.sas.tmss.tmss.tmssapp.models import * from lofar.sas.tmss.tmss.tmssapp.conversions import antennafields_for_antennaset_and_station import logging @@ -103,6 +104,7 @@ def process_subtask_feedback(subtask:Subtask): antennafields = input_dataproduct.feedback_doc["antennas"]['fields'] pointing = input_dataproduct.feedback_doc["target"]['pointing'] + # add feedback doc to dataproduct dataproduct.feedback_doc={ "percentage_written": int(feedback_dict[dpkey+'.percentageWritten']), @@ -113,7 +115,7 @@ def process_subtask_feedback(subtask:Subtask): "channels_per_subband": int(feedback_dict[dpkey + '.channelsPerSubband']) }, "time": { - "start_time": feedback_dict[dpkey+'.startTime'], + "start_time": parser.parse(feedback_dict[dpkey+'.startTime'], ignoretz=True).isoformat(), "duration": duration, "sample_width": float(feedback_dict[dpkey+'.integrationInterval']), }, diff --git a/SAS/TMSS/test/t_adapter.py b/SAS/TMSS/test/t_adapter.py index 4b11c380b6f06edc6a44e5985d8ce6c61197d671..375b2a71e39809175d5b7b54ef47bbbbe24b3451 100755 --- a/SAS/TMSS/test/t_adapter.py +++ b/SAS/TMSS/test/t_adapter.py @@ -24,7 +24,7 @@ import unittest import requests import logging -logger = logging.getLogger(__name__) +logger = logging.getLogger('lofar.'+__name__) logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', level=logging.INFO) # Do Mandatory setup step: @@ -70,8 +70,6 @@ class SIPadapterTest(unittest.TestCase): Check the number of SIP identifiers are increased with 3 Check that all SIP identifiers are unique """ - nbr_expected_sip_identifiers_before_setup = len(models.SIPidentifier.objects.all()) - subtask_template = models.SubtaskTemplate.objects.get(name='observation control') specifications_doc = get_default_json_object_for_schema(subtask_template.schema) specifications_doc['stations']['filter'] = "HBA_210_250" @@ -83,12 +81,11 @@ class SIPadapterTest(unittest.TestCase): # Create SubTask(output) subtask_data = Subtask_test_data(subtask_template=subtask_template, specifications_doc=specifications_doc) subtask:models.Subtask = models.Subtask.objects.create(**subtask_data) - subtask.save() + subtask_output = models.SubtaskOutput.objects.create(**SubtaskOutput_test_data(subtask=subtask)) # Create Dataproduct - dataproduct: models.Dataproduct = models.Dataproduct.objects.create( - **Dataproduct_test_data(feedback_doc=feedback_doc, producer=subtask_output)) - dataproduct.save() + dataproduct: models.Dataproduct = models.Dataproduct.objects.create(**Dataproduct_test_data(feedback_doc=feedback_doc, producer=subtask_output)) + # Create SAP sap_template = models.SAPTemplate.objects.get(name="SAP") specifications_doc = get_default_json_object_for_schema(sap_template.schema) @@ -107,11 +104,6 @@ class SIPadapterTest(unittest.TestCase): self.assertIn(str(dataproduct.global_identifier.unique_identifier), sip.get_prettyxml()) self.assertIn(str(sap.global_identifier.unique_identifier), sip.get_prettyxml()) - all_sip_ids = list(models.SIPidentifier.objects.all()) - self.assertEqual(nbr_expected_sip_identifiers_before_setup+3, len(all_sip_ids)) - for sip_id in all_sip_ids: - self.assertEqual(models.SIPidentifier.objects.filter(unique_identifier=sip_id.unique_identifier).count(), 1) - class FeedbackAdapterTest(unittest.TestCase):