Skip to content
Snippets Groups Projects
Commit 6926758b authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-142: test with valid and invalid json specs against DUPPLO UC1 correlator...

TMSS-142: test with valid and invalid json specs against DUPPLO UC1 correlator schema from populated database
parent e2580f50
No related branches found
No related tags found
2 merge requests!98Resolve TMSS-142 and TMSS-141,!97Resolve TMSS-138
......@@ -105,118 +105,9 @@ class SubtaskValidationTest(unittest.TestCase):
self.assertTrue('invalid json' in str(context.exception).lower())
def test_validate_correlator_schema(self):
# initial correlator_schema for Dupplo UC1
subtask_template = self.create_subtask_template('''
{
"$id": "http://example.com/example.json",
"type": "object",
"$schema": "http://json-schema.org/draft-06/schema#",
"definitions": {
"pointing": {
"type": "object",
"additionalProperties": false,
"properties": {
"direction_type": {
"type": "string",
"title": "Reference frame",
"description": "",
"default": "J2000",
"enum": [
"J2000",
"SUN",
"MOON",
"MERCURY",
"VENUS",
"MARS",
"JUPITER",
"SATURN",
"URANUS",
"NEPTUNE",
"PLUTO"
]
},
"angle1": {
"type": "number",
"title": "Angle 1",
"description": "First angle (f.e. RA)",
"default": 0
},
"angle2": {
"type": "number",
"title": "Angle 2",
"description": "Second angle (f.e. DEC)",
"default": 0
}
}
}
},
"additionalProperties": false,
"properties": {
"duration": {
"type": "number",
"title": "Duration (seconds)",
"description": "Duration of this observation",
"default": 60,
"minimum": 1
},
"calibrator": {
"type": "object",
"additionalProperties": false,
"properties": {
"enabled": {
"type": "boolean",
"title": "Calibrator",
"description": "Replace targets by calibrators",
"default": false
},
"autoselect": {
"type": "boolean",
"title": "Auto-select",
"description": "Auto-select calibrator based on elevation",
"default": false
},
"pointing": {
"title": "Digital pointing",
"$ref": "#/definitions/pointing"
}
}
},
"channels_per_subband": {
"type": "integer",
"title": "Channels/subband",
"description": "Number of frequency bands per subband",
"default": 64,
"minimum": 8,
"enum": [
8,
16,
32,
64,
128,
256,
512,
1024
]
},
"integration_time": {
"type": "number",
"title": "Integration time (seconds)",
"description": "Desired integration period",
"default": 1,
"minimum": 0.1
},
"storage_cluster": {
"type": "string",
"title": "Storage cluster",
"description": "Cluster to write output to",
"default": "CEP4",
"enum": [
"CEP4",
"DragNet"
]
}
}
}''')
# fetch correlator_schema for Dupplo UC1 which should be in the initially populated database
subtask_template = models.SubtaskTemplate.objects.get(name='correlator schema')
self.assertIsNotNone(subtask_template)
specifications_doc = '''{ "duration": 10,
"calibrator": { "pointing": {} }
......@@ -226,6 +117,23 @@ class SubtaskValidationTest(unittest.TestCase):
subtask = models.Subtask.objects.create(**subtask_data)
self.assertIsNotNone(subtask)
def test_validate_correlator_schema_with_invalid_specification(self):
# fetch correlator_schema for Dupplo UC1 which should be in the initially populated database
subtask_template = models.SubtaskTemplate.objects.get(name='correlator schema')
self.assertIsNotNone(subtask_template)
# test with invalid json
with self.assertRaises(SpecificationException) as context:
subtask_data = Subtask_test_data(subtask_template, "bogus spec")
models.Subtask.objects.create(**subtask_data)
self.assertTrue('invalid json' in str(context.exception).lower())
# test with valid json, but not according to schema
with self.assertRaises(SpecificationException) as context:
specifications_doc = '''{ "duration": -10 }'''
subtask_data = Subtask_test_data(subtask_template, specifications_doc)
models.Subtask.objects.create(**subtask_data)
self.assertTrue('-10' in str(context.exception).lower())
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