Commit 238e3cd0 authored by Joern jkuensem's avatar Joern jkuensem

SW-104: Renamed choices to not use hungarian notation

parent 1686cf3d
......@@ -4252,7 +4252,7 @@ SAS/LSMR/src/lsmr/lsmrapp/__init__.py -text
SAS/LSMR/src/lsmr/lsmrapp/admin.py -text
SAS/LSMR/src/lsmr/lsmrapp/apps.py -text
SAS/LSMR/src/lsmr/lsmrapp/migrations/0001_initial.py -text
SAS/LSMR/src/lsmr/lsmrapp/migrations/0002_auto_20190517_1703.py -text
SAS/LSMR/src/lsmr/lsmrapp/migrations/0002_auto_20190605_1635.py -text
SAS/LSMR/src/lsmr/lsmrapp/migrations/0003_populate.py -text
SAS/LSMR/src/lsmr/lsmrapp/migrations/CMakeLists.txt -text
SAS/LSMR/src/lsmr/lsmrapp/migrations/__init__.py -text
......
......@@ -6,7 +6,7 @@ from ..populate import *
class Migration(migrations.Migration):
dependencies = [
('lsmrapp', '0002_auto_20190517_1703'),
('lsmrapp', '0002_auto_20190605_1635'),
]
operations = [ migrations.RunPython(populate_choices) ]
......@@ -17,9 +17,9 @@ class SubtaskConnector(BasicCommon):
Represents the relation between input and output of the Subtasks. Some of these relations implement the Task
Relations. An input is tied to an output of another Subtask, and allows a filter to be specified.
"""
role = ForeignKey('RoleChoice', null=False, on_delete=PROTECT)
datatype = ForeignKey('DatatypeChoice', null=False, on_delete=PROTECT)
dataformats = ManyToManyField('DataformatChoice', blank=True)
role = ForeignKey('Role', null=False, on_delete=PROTECT)
datatype = ForeignKey('Datatype', null=False, on_delete=PROTECT)
dataformats = ManyToManyField('Dataformat', blank=True)
output_of = ForeignKey('SubtaskTemplate', related_name='inputs', blank=True, on_delete=PROTECT)
input_of = ForeignKey('SubtaskTemplate', related_name='outputs', blank=True, on_delete=PROTECT)
......@@ -28,7 +28,7 @@ class SubtaskConnector(BasicCommon):
# Choices
#
class SubtaskStateChoice(AbstractChoice):
class SubtaskState(AbstractChoice):
"""Defines the model and predefined list of possible SubtaskStatusChoice's for Subtask.
The items in the Choices class below are automagically populated into the database via a data migration."""
class Choices(Enum):
......@@ -47,8 +47,8 @@ class SubtaskStateChoice(AbstractChoice):
ERROR = "error"
class SubtaskTypeChoice(AbstractChoice):
"""Defines the model and predefined list of possible SubtaskTypeChoice's for Subtask.
class SubtaskType(AbstractChoice):
"""Defines the model and predefined list of possible SubtaskType's for Subtask.
The items in the Choices class below are automagically populated into the database via a data migration."""
class Choices(Enum):
OBSERVATION = "observation"
......@@ -60,8 +60,8 @@ class SubtaskTypeChoice(AbstractChoice):
OTHER = 'other'
class StationTypeChoice(AbstractChoice):
"""Defines the model and predefined list of possible StationTypeChoice's for AntennaSet.
class StationType(AbstractChoice):
"""Defines the model and predefined list of possible StationType's for AntennaSet.
The items in the Choices class below are automagically populated into the database via a data migration."""
class Choices(Enum):
......@@ -93,7 +93,7 @@ class ScheduleMethod(AbstractChoice):
#
class SubtaskTemplate(Template):
type = ForeignKey('SubtaskTypeChoice', null=False, on_delete=PROTECT)
type = ForeignKey('SubtaskType', null=False, on_delete=PROTECT)
queue = BooleanField(default=False)
realtime = BooleanField(default=False)
......@@ -136,7 +136,7 @@ class Subtask(BasicCommon):
"""
start_time = DateTimeField(null=True, help_text='Start this subtask at the specified time (NULLable).')
stop_time = DateTimeField(null=True, help_text='Stop this subtask at the specified time (NULLable).')
state = ForeignKey('SubtaskStateChoice', null=False, on_delete=PROTECT, related_name='task_states', help_text='Subtask state (see Subtask State Machine).')
state = ForeignKey('SubtaskState', null=False, on_delete=PROTECT, related_name='task_states', help_text='Subtask state (see Subtask State Machine).')
specifications_doc = JSONField(help_text='Final specifications, as input for the controller.')
task_blueprint = ForeignKey('TaskBlueprint', related_name='subtasks', null=True, on_delete=SET_NULL, help_text='Task Blueprint to which this Subtask belongs.')
specifications_template = ForeignKey('SubtaskTemplate', null=False, on_delete=PROTECT, help_text='Schema used for specifications_doc.')
......@@ -172,7 +172,7 @@ class Dataproduct(BasicCommon):
"""
filename = CharField(max_length=128, help_text='Name of the file (or top-level directory) of the dataproduct. Adheres to a naming convention, but is not meant for parsing.')
directory = CharField(max_length=1024, help_text='Directory where this dataproduct is (to be) stored.')
dataformat = ForeignKey('DataformatChoice', null=False, on_delete=PROTECT)
dataformat = ForeignKey('Dataformat', null=False, on_delete=PROTECT)
deleted_since = DateTimeField(null=True, help_text='When this dataproduct was removed from disk, or NULL if not deleted (NULLable).')
pinned_since = DateTimeField(null=True, help_text='When this dataproduct was pinned to disk, that is, forbidden to be removed, or NULL if not pinned (NULLable).')
specifications_doc = JSONField(help_text='Dataproduct properties (f.e. beam, subband), to distinguish them when produced by the same task, and to act as input for selections in the Task Input and Work Request Relation Blueprint objects.')
......@@ -186,7 +186,7 @@ class Dataproduct(BasicCommon):
class AntennaSet(NamedCommon):
station_type = ForeignKey('StationTypeChoice', null=False, on_delete=PROTECT)
station_type = ForeignKey('StationType', null=False, on_delete=PROTECT)
rcus = ArrayField(IntegerField(), size=128, blank=False)
inputs = ArrayField(CharField(max_length=128), size=128, blank=True)
......
......@@ -79,8 +79,8 @@ class AbstractChoice(Model):
return self.value
class RoleChoice(AbstractChoice):
"""Defines the model and predefined list of possible RoleChoice's for TaskConnectors.
class Role(AbstractChoice):
"""Defines the model and predefined list of possible Role's for TaskConnectors.
The items in the Choises class below are automagically populated into the database via a data migration."""
class Choices(Enum):
CORRELATOR = "correlator"
......@@ -92,8 +92,8 @@ class RoleChoice(AbstractChoice):
OUTPUT = "output"
class DatatypeChoice(AbstractChoice):
"""Defines the model and predefined list of possible DatatypeChoice's for TaskConnectors.
class Datatype(AbstractChoice):
"""Defines the model and predefined list of possible Datatype's for TaskConnectors.
The items in the Choises class below are automagically populated into the database via a data migration."""
class Choices(Enum):
VISIBILITIES = "visibilities"
......@@ -103,16 +103,16 @@ class DatatypeChoice(AbstractChoice):
QUALITY = "quality"
class DataformatChoice(AbstractChoice):
"""Defines the model and predefined list of possible DataformatChoice's for TaskRelationDraft and TaskRelationBlueprint.
class Dataformat(AbstractChoice):
"""Defines the model and predefined list of possible Dataformat's for TaskRelationDraft and TaskRelationBlueprint.
The items in the Choises class below are automagically populated into the database via a data migration."""
class Choices(Enum):
MEASUREMENTSET = "MeasurementSet"
BEAMFORMED = "Beamformed"
class CopyReasonChoice(AbstractChoice):
"""Defines the model and predefined list of possible CopyReasonChoice's for SchedulingUnitDraft and TaskDraft.
class CopyReason(AbstractChoice):
"""Defines the model and predefined list of possible CopyReason's for SchedulingUnitDraft and TaskDraft.
The items in the Choises class below are automagically populated into the database via a data migration."""
class Choices(Enum):
TEMPLATE = "template"
......@@ -122,9 +122,9 @@ class CopyReasonChoice(AbstractChoice):
# concrete models
class TaskConnectors(BasicCommon):
role = ForeignKey('RoleChoice', null=False, on_delete=PROTECT)
datatype = ForeignKey('DatatypeChoice', null=False, on_delete=PROTECT)
dataformats = ManyToManyField('DataformatChoice', blank=True)
role = ForeignKey('Role', null=False, on_delete=PROTECT)
datatype = ForeignKey('Datatype', null=False, on_delete=PROTECT)
dataformats = ManyToManyField('Dataformat', blank=True)
output_of = ForeignKey("TaskTemplate", related_name='outputs', on_delete=CASCADE)
input_of = ForeignKey("TaskTemplate", related_name='inputs', on_delete=CASCADE)
......@@ -218,7 +218,7 @@ class SchedulingSet(NamedCommon):
class SchedulingUnitDraft(NamedCommon):
requirements_doc = JSONField(help_text='Scheduling and/or quality requirements for this run.')
copies = ForeignKey('SchedulingUnitDraft', related_name="copied_from", on_delete=SET_NULL, null=True, help_text='Source reference, if we are a copy (NULLable).')
copy_reason = ForeignKey('CopyReasonChoice', null=True, on_delete=PROTECT, help_text='Reason why source was copied (NULLable).')
copy_reason = ForeignKey('CopyReason', null=True, on_delete=PROTECT, help_text='Reason why source was copied (NULLable).')
generator_instance_doc = JSONField(null=True, help_text='Parameter value that generated this run draft (NULLable).')
scheduling_set = ForeignKey('SchedulingSet', related_name='scheduling_unit_drafts', on_delete=CASCADE, help_text='Set to which this scheduling unit draft belongs.')
requirements_template = ForeignKey('SchedulingUnitTemplate', on_delete=CASCADE, help_text='Schema used for requirements_doc.') # todo: 'schema'?
......@@ -234,7 +234,7 @@ class SchedulingUnitBlueprint(NamedCommon):
class TaskDraft(NamedCommon):
specifications_doc = JSONField(help_text='Specifications for this task.')
copies = ForeignKey('TaskDraft', related_name="copied_from", on_delete=SET_NULL, null=True, help_text='Source reference, if we are a copy (NULLable).')
copy_reason = ForeignKey('CopyReasonChoice', on_delete=PROTECT, null=True, help_text='Reason why source was copied (NULLable).')
copy_reason = ForeignKey('CopyReason', on_delete=PROTECT, null=True, help_text='Reason why source was copied (NULLable).')
scheduling_unit_draft = ForeignKey('SchedulingUnitDraft', related_name='task_drafts', on_delete=CASCADE, help_text='Scheduling Unit draft to which this task draft belongs.')
specifications_template = ForeignKey('TaskTemplate', on_delete=CASCADE, help_text='Schema used for requirements_doc.') # todo: 'schema'?
......@@ -249,7 +249,7 @@ class TaskBlueprint(NamedCommon):
class TaskRelationDraft(BasicCommon):
selection_doc = JSONField(help_text='Filter for selecting dataproducts from the output role.')
dataformat = ForeignKey('DataformatChoice', null=False, on_delete=PROTECT, help_text='Selected data format to use. One of (MS, HDF5).')
dataformat = ForeignKey('Dataformat', null=False, on_delete=PROTECT, help_text='Selected data format to use. One of (MS, HDF5).')
producer = ForeignKey('TaskDraft', related_name='produced_by', on_delete=CASCADE, help_text='Task Draft that has the output connector. NOTE: The producer does typically, but not necessarily, belong to the same Scheduling Unit (or even the same Project) as the consumer.')
consumer = ForeignKey('TaskDraft', related_name='consumed_by', on_delete=CASCADE, help_text='Task Draft that has the input connector.')
input = ForeignKey('TaskConnectors', related_name='inputs_task_relation_draft', on_delete=CASCADE, help_text='Input connector of consumer.')
......@@ -259,7 +259,7 @@ class TaskRelationDraft(BasicCommon):
class TaskRelationBlueprint(BasicCommon):
selection_doc = JSONField(help_text='Filter for selecting dataproducts from the output role.')
dataformat = ForeignKey('DataformatChoice', null=False, on_delete=PROTECT, help_text='Selected data format to use.')
dataformat = ForeignKey('Dataformat', null=False, on_delete=PROTECT, help_text='Selected data format to use.')
producer = ForeignKey('TaskBlueprint', related_name='produced_by', on_delete=CASCADE, help_text='Task Blueprint that has the output connector.')
consumer = ForeignKey('TaskBlueprint', related_name='consumed_by', on_delete=CASCADE, help_text='Task Blueprint that has the input connector.')
input = ForeignKey('TaskConnectors', related_name='inputs_task_relation_blueprint', on_delete=CASCADE, help_text='Input connector of consumer.')
......
......@@ -15,16 +15,16 @@ class Migration(migrations.Migration):
"""
from .models.specification import RoleChoice, DatatypeChoice, DataformatChoice, CopyReasonChoice
from .models.scheduling import SubtaskStateChoice, SubtaskTypeChoice, StationTypeChoice, Algorithm, ScheduleMethod
from .models.specification import Role, Datatype, Dataformat, CopyReason
from .models.scheduling import SubtaskState, SubtaskType, StationType, Algorithm, ScheduleMethod
def populate_choices(apps, schema_editor):
'''
populate each 'choice' table in the database with the 'static' list of 'choice'.Choices for
each 'choice'type in RoleChoice, DatatypeChoice, DataformatChoice, CopyReasonChoice
each 'choice'type in Role, Datatype, Dataformat, CopyReason
:return: None
'''
for choice_class in [RoleChoice, DatatypeChoice, DataformatChoice, CopyReasonChoice,
SubtaskStateChoice, SubtaskTypeChoice, StationTypeChoice, Algorithm, ScheduleMethod]:
for choice_class in [Role, Datatype, Dataformat, CopyReason,
SubtaskState, SubtaskType, StationType, Algorithm, ScheduleMethod]:
choice_class.objects.bulk_create([choice_class(value=x.value) for x in choice_class.Choices])
......@@ -13,21 +13,21 @@ class SubtaskConnectorSerializer(serializers.HyperlinkedModelSerializer):
fields = '__all__'
class SubtaskStateChoiceSerializer(serializers.ModelSerializer):
class SubtaskStateSerializer(serializers.ModelSerializer):
class Meta:
model = models.SubtaskStateChoice
model = models.SubtaskState
fields = '__all__'
class SubtaskTypeChoiceSerializer(serializers.ModelSerializer):
class SubtaskTypeSerializer(serializers.ModelSerializer):
class Meta:
model = models.SubtaskTypeChoice
model = models.SubtaskType
fields = '__all__'
class StationTypeChoiceSerializer(serializers.ModelSerializer):
class StationTypeSerializer(serializers.ModelSerializer):
class Meta:
model = models.StationTypeChoice
model = models.StationType
fields = '__all__'
......
......@@ -71,27 +71,27 @@ class DefaultWorkRelationSelectionTemplateSerializer(serializers.HyperlinkedMode
fields = '__all__'
class RoleChoiceSerializer(serializers.ModelSerializer):
class RoleSerializer(serializers.ModelSerializer):
class Meta:
model = models.RoleChoice
model = models.Role
fields = '__all__'
class DatatypeChoiceSerializer(serializers.ModelSerializer):
class DatatypeSerializer(serializers.ModelSerializer):
class Meta:
model = models.DatatypeChoice
model = models.Datatype
fields = '__all__'
class DataformatChoiceSerializer(serializers.ModelSerializer):
class DataformatSerializer(serializers.ModelSerializer):
class Meta:
model = models.DataformatChoice
model = models.Dataformat
fields = '__all__'
class CopyReasonChoiceSerializer(serializers.ModelSerializer):
class CopyReasonSerializer(serializers.ModelSerializer):
class Meta:
model = models.CopyReasonChoice
model = models.CopyReason
fields = '__all__'
......
......@@ -13,19 +13,19 @@ class SubtaskConnectorViewSet(LOFARViewSet):
serializer_class = serializers.SubtaskConnectorSerializer
class SubtaskStateChoiceViewSet(LOFARViewSet):
queryset = models.SubtaskStateChoice.objects.all()
serializer_class = serializers.SubtaskStateChoiceSerializer
class SubtaskStateViewSet(LOFARViewSet):
queryset = models.SubtaskState.objects.all()
serializer_class = serializers.SubtaskStateSerializer
class SubtaskTypeChoiceViewSet(LOFARViewSet):
queryset = models.SubtaskTypeChoice.objects.all()
serializer_class = serializers.SubtaskTypeChoiceSerializer
class SubtaskTypeViewSet(LOFARViewSet):
queryset = models.SubtaskType.objects.all()
serializer_class = serializers.SubtaskTypeSerializer
class StationTypeChoiceViewSet(LOFARViewSet):
queryset = models.StationTypeChoice.objects.all()
serializer_class = serializers.StationTypeChoiceSerializer
class StationTypeViewSet(LOFARViewSet):
queryset = models.StationType.objects.all()
serializer_class = serializers.StationTypeSerializer
class AlgorithmViewSet(LOFARViewSet):
......
......@@ -53,24 +53,24 @@ class DefaultWorkRelationSelectionTemplateViewSet(LOFARViewSet):
serializer_class = serializers.DefaultWorkRelationSelectionTemplateSerializer
class RoleChoiceViewSet(LOFARViewSet):
queryset = models.RoleChoice.objects.all()
serializer_class = serializers.RoleChoiceSerializer
class RoleViewSet(LOFARViewSet):
queryset = models.Role.objects.all()
serializer_class = serializers.RoleSerializer
class DatatypeChoiceViewSet(LOFARViewSet):
queryset = models.DatatypeChoice.objects.all()
serializer_class = serializers.DatatypeChoiceSerializer
class DatatypeViewSet(LOFARViewSet):
queryset = models.Datatype.objects.all()
serializer_class = serializers.DatatypeSerializer
class DataformatChoiceViewSet(LOFARViewSet):
queryset = models.DataformatChoice.objects.all()
serializer_class = serializers.DataformatChoiceSerializer
class DataformatViewSet(LOFARViewSet):
queryset = models.Dataformat.objects.all()
serializer_class = serializers.DataformatSerializer
class CopyReasonChoiceViewSet(LOFARViewSet):
queryset = models.CopyReasonChoice.objects.all()
serializer_class = serializers.CopyReasonChoiceSerializer
class CopyReasonViewSet(LOFARViewSet):
queryset = models.CopyReason.objects.all()
serializer_class = serializers.CopyReasonSerializer
class TaskConnectorsViewSet(LOFARViewSet):
......
......@@ -62,10 +62,10 @@ router.register(r'tags', viewsets.TagsViewSet)
# SPECIFICATION
# choices
router.register(r'role_choice', viewsets.RoleChoiceViewSet)
router.register(r'datatype_choice', viewsets.DatatypeChoiceViewSet)
router.register(r'dataformat_choice', viewsets.DataformatChoiceViewSet)
router.register(r'copy_reason_choice', viewsets.CopyReasonChoiceViewSet)
router.register(r'role', viewsets.RoleViewSet)
router.register(r'datatype', viewsets.DatatypeViewSet)
router.register(r'dataformat', viewsets.DataformatViewSet)
router.register(r'copy_reason', viewsets.CopyReasonViewSet)
# templates
router.register(r'generator_template', viewsets.GeneratorTemplateViewSet)
......@@ -103,9 +103,9 @@ router.register(r'task_blueprint/(?P<task_blueprint_pk>\d+)/subtask', viewsets.S
# SCHEDULING
# choices
router.register(r'subtask_state_choice', viewsets.SubtaskStateChoiceViewSet)
router.register(r'subtask_type_choice', viewsets.SubtaskTypeChoiceViewSet)
router.register(r'station_type_choice', viewsets.StationTypeChoiceViewSet)
router.register(r'subtask_state', viewsets.SubtaskStateViewSet)
router.register(r'subtask_type', viewsets.SubtaskTypeViewSet)
router.register(r'station_type', viewsets.StationTypeViewSet)
router.register(r'algorithm', viewsets.AlgorithmViewSet)
router.register(r'schedule_method', viewsets.ScheduleMethodViewSet)
......
......@@ -146,7 +146,7 @@ def _dummy_scheduling_unit_draft(scheduling_set, template):
"description": "Dummy scheduling_unit draft",
"tags": ["DUMMY"],
"requirements_doc": "{}",
"copy_reason": models.CopyReasonChoice.objects.get(value='template'),
"copy_reason": models.CopyReason.objects.get(value='template'),
"generator_instance_doc": "para",
"copies": None,
"scheduling_set": scheduling_set,
......@@ -188,7 +188,7 @@ def _dummy_task_draft(scheduling_unit_draft, template):
"description": "Dummy work request draft",
"tags": ["DUMMY"],
"requirements_doc": "{}",
"copy_reason": models.CopyReasonChoice.objects.get(value='template'),
"copy_reason": models.CopyReason.objects.get(value='template'),
"copies": None,
"scheduling_unit_draft": scheduling_unit_draft,
"template": template}
......@@ -223,12 +223,12 @@ def get_subtask_details_from_momdb(project_mom2id, project):
# (maybe we want to instead separate these into different queries instead or union them in SQL?)
if 'OBSERVATION' in mom_details['mom2objecttype']:
type = models.SubtaskTypeChoice.objects.get(value='observation')
type = models.SubtaskType.objects.get(value='observation')
template_name = mom_details['default_template']
start_time = mom_details['obs_starttime']
end_time = mom_details['obs_endtime']
elif 'PIPELINE' in mom_details['mom2objecttype']:
type = models.SubtaskTypeChoice.objects.get(value='pipeline')
type = models.SubtaskType.objects.get(value='pipeline')
template_name = mom_details['template']
start_time = mom_details['starttime']
end_time = mom_details['endtime']
......@@ -264,7 +264,7 @@ def get_subtask_details_from_momdb(project_mom2id, project):
# state
try:
state = models.SubtaskStateChoice.objects.get(value=mom_details['code'])
state = models.SubtaskState.objects.get(value=mom_details['code'])
details['state'] = state
details['requested_state'] = state
except Exception as e:
......
......@@ -44,7 +44,7 @@ class SubtaskTemplateTest(rest_framework.test.APITransactionTestCase):
print("why is this happening!? Continuing anyway...")
# test data
self.test_data_1 = {"type": models.SubtaskTypeChoice.objects.get(value='copy'),
self.test_data_1 = {"type": models.SubtaskType.objects.get(value='copy'),
"name": "observation",
"description": 'My one observation',
"version": 'v0.314159265359',
......@@ -53,7 +53,7 @@ class SubtaskTemplateTest(rest_framework.test.APITransactionTestCase):
"queue": False,
"tags": ["LSMR", "TESTING"]}
self.test_data_2 = {"type": models.SubtaskTypeChoice.objects.get(value='pipeline'),
self.test_data_2 = {"type": models.SubtaskType.objects.get(value='pipeline'),
"name": "observation",
"description": 'My other observation',
"version": 'v0.314159265359',
......@@ -488,7 +488,7 @@ class SubtaskTest(rest_framework.test.APITransactionTestCase):
self.test_data_1 = {
"start_time": datetime.utcnow().isoformat(),
"stop_time": datetime.utcnow().isoformat(),
"state": models.SubtaskStateChoice.objects.get(value='scheduling'),
"state": models.SubtaskState.objects.get(value='scheduling'),
"specifications_doc": "{}",
"task_blueprint": models.TaskBlueprint.objects.create(**wrbt.test_data_1),
"specifications_template": models.SubtaskTemplate.objects.create(**sst.test_data_1),
......@@ -502,7 +502,7 @@ class SubtaskTest(rest_framework.test.APITransactionTestCase):
self.test_data_2 = {
"start_time": datetime.utcnow().isoformat(),
"stop_time": datetime.utcnow().isoformat(),
"state": models.SubtaskStateChoice.objects.get(value='queueing'),
"state": models.SubtaskState.objects.get(value='queueing'),
"specifications_doc": "{'some': 'spec'}",
"task_blueprint": models.TaskBlueprint.objects.create(**wrbt.test_data_2),
"specifications_template": models.SubtaskTemplate.objects.create(**sst.test_data_2),
......@@ -620,7 +620,7 @@ class DataproductTest(rest_framework.test.APITransactionTestCase):
# test data
self.test_data_1 = {"filename": "my.file",
"directory": "/home/boskabouter/",
"dataformat": models.DataformatChoice.objects.get(value='Beamformed'),
"dataformat": models.Dataformat.objects.get(value='Beamformed'),
"deleted_since": datetime.utcnow().isoformat(),
"pinned_since": datetime.utcnow().isoformat(),
"specifications_doc": "{}",
......@@ -635,7 +635,7 @@ class DataproductTest(rest_framework.test.APITransactionTestCase):
self.test_data_2 = {"filename": "my_other.file",
"directory": "/home/boskabouter/",
"dataformat": models.DataformatChoice.objects.get(value='MeasurementSet'),
"dataformat": models.Dataformat.objects.get(value='MeasurementSet'),
"deleted_since": datetime.utcnow().isoformat(),
"pinned_since": datetime.utcnow().isoformat(),
"specifications_doc": "{}",
......@@ -731,16 +731,16 @@ class SubtaskConnectorTest(rest_framework.test.APITransactionTestCase):
sst.setUp(populate=False)
# test data
self.test_data_1 = {"role": models.RoleChoice.objects.get(value='calibrator'),
"datatype": models.DatatypeChoice.objects.get(value='instrument model'),
# "dataformats": [models.DataformatChoice.objects.get(value='Beamformed')], # -> use set()
self.test_data_1 = {"role": models.Role.objects.get(value='calibrator'),
"datatype": models.Datatype.objects.get(value='instrument model'),
# "dataformats": [models.Dataformat.objects.get(value='Beamformed')], # -> use set()
"output_of": models.SubtaskTemplate.objects.create(**sst.test_data_1),
"input_of": models.SubtaskTemplate.objects.create(**sst.test_data_2),
"tags": []}
self.test_data_2 = {"role": models.RoleChoice.objects.get(value='target'),
"datatype": models.DatatypeChoice.objects.get(value='image'),
# "dataformats": [models.DataformatChoice.objects.get(value='MeasurementSet')], # -> use set()
self.test_data_2 = {"role": models.Role.objects.get(value='target'),
"datatype": models.Datatype.objects.get(value='image'),
# "dataformats": [models.Dataformat.objects.get(value='MeasurementSet')], # -> use set()
"output_of": models.SubtaskTemplate.objects.create(**sst.test_data_1),
"input_of": models.SubtaskTemplate.objects.create(**sst.test_data_2),
"tags": []}
......@@ -800,8 +800,8 @@ class SubtaskConnectorTest(rest_framework.test.APITransactionTestCase):
test_data_1 = dict(self.test_data_1)
test_data_1['inputs'] = None
tior = models.SubtaskConnector.objects.create(**self.test_data_2)
tior.dataformats.set([models.DataformatChoice.objects.get(value='Beamformed'),
models.DataformatChoice.objects.get(value='MeasurementSet')])
tior.dataformats.set([models.Dataformat.objects.get(value='Beamformed'),
models.Dataformat.objects.get(value='MeasurementSet')])
tior.save()
# assert
......@@ -828,14 +828,14 @@ class AntennaSetTest(rest_framework.test.APITransactionTestCase):
# test data
self.test_data_1 = {"name": "observation",
"description": 'My one observation',
"station_type": models.StationTypeChoice.objects.get(value='core'),
"station_type": models.StationType.objects.get(value='core'),
"rcus": [1,2,3,4,5],
"inputs": ['input1', 'input2'],
"tags": ['lsmr', 'testing']}
self.test_data_2 = {"name": "observation",
"description": 'My one observation',
"station_type": models.StationTypeChoice.objects.get(value='international'),
"station_type": models.StationType.objects.get(value='international'),
"rcus": [],
"inputs": [],
"tags": []}
......
......@@ -389,14 +389,14 @@ class TaskConnectorsTest(rest_framework.test.APITransactionTestCase):
populate_choices(None, None) # <- can only be called once per test case
# test data
self.test_data_1 = {"role": models.RoleChoice.objects.get(value='calibrator'),
"datatype": models.DatatypeChoice.objects.get(value='instrument model'),
self.test_data_1 = {"role": models.Role.objects.get(value='calibrator'),
"datatype": models.Datatype.objects.get(value='instrument model'),
"output_of": models.TaskTemplate.objects.create(**TaskTemplateTest.test_data_1),
"input_of": models.TaskTemplate.objects.create(**TaskTemplateTest.test_data_2),
"tags": []}
self.test_data_2 = {"role": models.RoleChoice.objects.get(value='target'),
"datatype": models.DatatypeChoice.objects.get(value='image'),
self.test_data_2 = {"role": models.Role.objects.get(value='target'),
"datatype": models.Datatype.objects.get(value='image'),
"output_of": models.TaskTemplate.objects.create(**TaskTemplateTest.test_data_2),
"input_of": models.TaskTemplate.objects.create(**TaskTemplateTest.test_data_1),
"tags": []}
......@@ -454,8 +454,8 @@ class TaskConnectorsTest(rest_framework.test.APITransactionTestCase):
test_data_1 = dict(self.test_data_1)
test_data_1['input_of'] = None
wior = models.TaskConnectors.objects.create(**self.test_data_2)
wior.dataformats.set([models.DataformatChoice.objects.get(value='Beamformed'),
models.DataformatChoice.objects.get(value='MeasurementSet')])
wior.dataformats.set([models.Dataformat.objects.get(value='Beamformed'),
models.Dataformat.objects.get(value='MeasurementSet')])
wior.save()
# assert
......@@ -805,7 +805,7 @@ class SchedulingUnitDraftTest(rest_framework.test.APITransactionTestCase):
"description": "",
"tags": [],
"requirements_doc": "{}",
"copy_reason": models.CopyReasonChoice.objects.get(value='template'),
"copy_reason": models.CopyReason.objects.get(value='template'),
"generator_instance_doc": "para",
"copies": None,
"scheduling_set": models.SchedulingSet.objects.create(**self.sst.test_data_1),
......@@ -816,7 +816,7 @@ class SchedulingUnitDraftTest(rest_framework.test.APITransactionTestCase):
"description": "",
"tags": [],
"requirements_doc": "{}",
"copy_reason": models.CopyReasonChoice.objects.get(value='repeated'), # todo: should this require copies to be assigned another SchedulingUnitDraft? Or isn't this implicit, actually?
"copy_reason": models.CopyReason.objects.get(value='repeated'), # todo: should this require copies to be assigned another SchedulingUnitDraft? Or isn't this implicit, actually?
"generator_instance_doc": "meter",
"copies": None,
"scheduling_set": models.SchedulingSet.objects.create(**self.sst.test_data_2),
......@@ -982,7 +982,7 @@ class TaskDraftTest(rest_framework.test.APITransactionTestCase):
"description": "",
"tags": [],
"specifications_doc": "{}",
"copy_reason": models.CopyReasonChoice.objects.get(value='template'),
"copy_reason": models.CopyReason.objects.get(value='template'),
"copies": None,
"scheduling_unit_draft": models.SchedulingUnitDraft.objects.create(**self.sudt.test_data_1),
"specifications_template": models.TaskTemplate.objects.create(**TaskTemplateTest.test_data_1)}
......@@ -992,7 +992,7 @@ class TaskDraftTest(rest_framework.test.APITransactionTestCase):
"description": "",
"tags": [],
"specifications_doc": "{}",
"copy_reason": models.CopyReasonChoice.objects.get(value='repeated'), # todo: should this require copies to be assigned another SchedulingUnitDraft? Or isn't this implicit, actually?
"copy_reason": models.CopyReason.objects.get(value='repeated'), # todo: should this require copies to be assigned another SchedulingUnitDraft? Or isn't this implicit, actually?
"copies": None,
"scheduling_unit_draft": models.SchedulingUnitDraft.objects.create(**self.sudt.test_data_2),
"specifications_template": models.TaskTemplate.objects.create(**TaskTemplateTest.test_data_2)}
......@@ -1162,7 +1162,7 @@ class TaskRelationDraftTest(rest_framework.test.APITransactionTestCase):
# test data
self.test_data_1 = {"tags": [],
"selection_doc": "{}",
"dataformat": models.DataformatChoice.objects.get(value='Beamformed'),
"dataformat": models.Dataformat.objects.get(value='Beamformed'),
"producer": models.TaskDraft.objects.create(**self.wrdt.test_data_1),
"consumer": models.TaskDraft.objects.create(**self.wrdt.test_data_2),
"input": models.TaskConnectors.objects.create(**self.wiort.test_data_1),
......@@ -1172,7 +1172,7 @@ class TaskRelationDraftTest(rest_framework.test.APITransactionTestCase):
# test data
self.test_data_2 = {"tags": [],
"selection_doc": "{}",
"dataformat": models.DataformatChoice.objects.get(value='MeasurementSet'),
"dataformat": models.Dataformat.objects.get(value='MeasurementSet'),
"producer": models.TaskDraft.objects.create(**self.wrdt.test_data_2),
"consumer": models.TaskDraft.objects.create(**self.wrdt.test_data_1),
"input": models.TaskConnectors.objects.create(**self.wiort.test_data_2),
......@@ -1648,7 +1648,7 @@ class TaskRelationBlueprintTest(rest_framework.test.APITransactionTestCase):
# test data
self.test_data_1 = {"tags": [],
"selection_doc": "{}",
"dataformat": models.DataformatChoice.objects.get(value='Beamformed'),
"dataformat": models.Dataformat.objects.get(value='Beamformed'),
"input": models.TaskConnectors.objects.create(**self.wiort.test_data_1),
"output": models.TaskConnectors.objects.create(**self.wiort.test_data_2),
"draft": models.TaskRelationDraft.objects.create(**self.wrrdt.test_data_1),
......@@ -1659,7 +1659,7 @@ class TaskRelationBlueprintTest(rest_framework.test.APITransactionTestCase):
# test data
self.test_data_2 = {"tags": [],
"selection_doc": "{}",
"dataformat": models.DataformatChoice.objects.get(value='Beamformed'),
"dataformat": models.Dataformat.objects.get(value='Beamformed'),
"input": models.TaskConnectors.objects.create(**self.wiort.test_data_1),
"output": models.TaskConnectors.objects.create(**self.wiort.test_data_2),
"draft": models.TaskRelationDraft.objects.create(**self.wrrdt.test_data_2),
......
......@@ -453,23 +453,23 @@ class TaskConnectorsTestCase(unittest.TestCase):
TaskTemplateTestCase.test_data_2)['url']
# test data
self.test_data_1 = {"role": BASE_URL + '/role_choice/correlator/',
"datatype": BASE_URL + '/datatype_choice/image/',
"dataformats": [BASE_URL + '/dataformat_choice/Beamformed/'],
self.test_data_1 = {"role": BASE_URL + '/role/correlator/',
"datatype": BASE_URL + '/datatype/image/',
"dataformats": [BASE_URL + '/dataformat/Beamformed/'],
"output_of": output_of_url,
"input_of": input_of_url,
"tags": []}
self.test_data_2 = {"role": BASE_URL + '/role_choice/target/',
"datatype": BASE_URL + '/datatype_choice/visibilities/',
"dataformats": [BASE_URL + '/dataformat_choice/MeasurementSet/'],
self.test_data_2 = {"role": BASE_URL + '/role/target/',
"datatype": BASE_URL + '/datatype/visibilities/',
"dataformats": [BASE_URL + '/dataformat/MeasurementSet/'],
"output_of": output_of_url,
"input_of": input_of_url,
"tags": []}
self.test_patch = {"role": BASE_URL + '/role_choice/calibrator/',
"dataformats": [BASE_URL + '/dataformat_choice/Beamformed/',
BASE_URL + '/dataformat_choice/MeasurementSet/']}
self.test_patch = {"role": BASE_URL + '/role/calibrator/',
"dataformats": [BASE_URL + '/dataformat/Beamformed/',
BASE_URL + '/dataformat/MeasurementSet/']}
def test_task_connectors_list_apiformat(self):
r = requests.get(BASE_URL + '/task_connectors/?format=api', auth=self.auth)
......@@ -489,7 +489,7 @@ class TaskConnectorsTestCase(unittest.TestCase):
# POST a new item with invalid choice
test_data_invalid_role = dict(self.test_data_1)
test_data_invalid_role['role'] = BASE_URL + '/role_choice/forbidden/'
test_data_invalid_role['role'] = BASE_URL + '/role/forbidden/'
r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_connectors/', test_data_invalid_role, 400, {})
self.assertTrue('Invalid hyperlink' in str(r_dict['role']))
......@@ -497,7 +497,7 @@ class TaskConnectorsTestCase(unittest.TestCase):
# POST a new item with invalid choice
test_data_invalid = dict(self.test_data_1)
test_data_invalid['datatype'] = BASE_URL + '/datatype_choice/forbidden/'
test_data_invalid['datatype'] = BASE_URL + '/datatype/forbidden/'
r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_connectors/', test_data_invalid, 400, {})
self.assertTrue('Invalid hyperlink' in str(r_dict['datatype']))
......@@ -505,7 +505,7 @@ class TaskConnectorsTestCase(unittest.TestCase):