Commit fd803b47 authored by Joern jkuensem's avatar Joern jkuensem

Task LEI-86: Adapt specification model and tests to match model changes

parent a2da40dd
......@@ -4247,7 +4247,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_20190417_1025.py -text
SAS/LSMR/src/lsmr/lsmrapp/migrations/0002_auto_20190425_1501.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_20190417_1025'),
('lsmrapp', '0002_auto_20190425_1501'),
]
operations = [ migrations.RunPython(populate_choices) ]
......@@ -5,7 +5,7 @@ This file contains the database models
from django.db.models import ForeignKey, CharField, DateTimeField, BooleanField, IntegerField, BigIntegerField, \
ManyToManyField, CASCADE, SET_NULL, PROTECT
from django.contrib.postgres.fields import ArrayField, JSONField
from .specification import AbstractChoice, BasicCommon, Template, NamedCommon # , WorkRequestBlueprint
from .specification import AbstractChoice, BasicCommon, Template, NamedCommon # , <TaskBlueprint
from enum import Enum
from rest_framework.serializers import HyperlinkedRelatedField
#
......@@ -94,7 +94,7 @@ class SubtaskTemplate(Template):
class DefaultSubtaskTemplate(BasicCommon):
name = CharField(max_length=30, unique=True)
name = CharField(max_length=128, unique=True)
template = ForeignKey('SubtaskTemplate', on_delete=PROTECT)
......@@ -103,7 +103,7 @@ class DataproductSpecificationsTemplate(Template):
class DefaultDataproductSpecificationsTemplate(BasicCommon):
name = CharField(max_length=30, unique=True)
name = CharField(max_length=128, unique=True)
template = ForeignKey('DataproductSpecificationsTemplate', on_delete=PROTECT)
......@@ -129,7 +129,7 @@ class Subtask(BasicCommon):
stop_time = DateTimeField()
state = ForeignKey('SubtaskStateChoice', null=False, on_delete=PROTECT, related_name='task_states')
specifications_doc = JSONField()
work_request_blueprint = ForeignKey('WorkRequestBlueprint', null=True, on_delete=SET_NULL)
task_blueprint = ForeignKey('TaskBlueprint', null=True, on_delete=SET_NULL)
specifications_template = ForeignKey('SubtaskTemplate', null=False, on_delete=PROTECT)
do_cancel = DateTimeField()
priority = IntegerField()
......@@ -173,7 +173,7 @@ class Dataproduct(BasicCommon):
class AntennaSet(NamedCommon):
station_type = ForeignKey('StationTypeChoice', null=False, on_delete=PROTECT)
rcus = ArrayField(IntegerField(), size=128, blank=False)
inputs = ArrayField(CharField(max_length=30), size=128, blank=True)
inputs = ArrayField(CharField(max_length=128), size=128, blank=True)
class DataproductTransform(BasicCommon):
......@@ -202,8 +202,3 @@ class DataproductHash(BasicCommon):
dataproduct = ForeignKey('Dataproduct', on_delete=PROTECT)
algorithm = ForeignKey('Algorithm', null=False, on_delete=PROTECT)
hash = CharField(max_length=128)
class TaskRelationBlueprint(BasicCommon):
# dummy, this will eventually come from the renaming of the WorkRelationBlueprint in LEI-86...
pass
\ No newline at end of file
......@@ -136,9 +136,3 @@ class DataproductHashSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = models.DataproductHash
fields = '__all__'
class TaskRelationBlueprintSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = models.TaskRelationBlueprint
fields = '__all__'
\ No newline at end of file
......@@ -25,27 +25,27 @@ class DefaultGeneratorTemplateSerializer(serializers.HyperlinkedModelSerializer)
fields = '__all__'
class RunTemplateSerializer(serializers.HyperlinkedModelSerializer):
class SpecificationUnitTemplateSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = models.RunTemplate
model = models.SpecificationUnitTemplate
fields = '__all__'
class DefaultRunTemplateSerializer(serializers.HyperlinkedModelSerializer):
class DefaultSpecificationUnitTemplateSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = models.DefaultRunTemplate
model = models.DefaultSpecificationUnitTemplate
fields = '__all__'
class WorkRequestTemplateSerializer(serializers.HyperlinkedModelSerializer):
class TaskTemplateSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = models.WorkRequestTemplate
model = models.TaskTemplate
fields = '__all__'
class DefaultWorkRequestTemplateSerializer(serializers.HyperlinkedModelSerializer):
class DefaultTaskTemplateSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = models.DefaultWorkRequestTemplate
model = models.DefaultTaskTemplate
fields = '__all__'
......@@ -85,9 +85,9 @@ class CopyReasonChoiceSerializer(serializers.ModelSerializer):
fields = '__all__'
class WorkIORoleSerializer(serializers.HyperlinkedModelSerializer):
class TaskConnectorsSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = models.WorkIORole
model = models.TaskConnectors
fields = '__all__'
......@@ -103,52 +103,52 @@ class ProjectSerializer(serializers.HyperlinkedModelSerializer):
fields = '__all__'
class RunSetSerializer(serializers.HyperlinkedModelSerializer):
class SpecificationSetSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = models.RunSet
model = models.SpecificationSet
fields = '__all__'
class RunDraftSerializer(serializers.HyperlinkedModelSerializer):
class SpecificationUnitDraftSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = models.RunDraft
model = models.SpecificationUnitDraft
fields = '__all__'
class RunBlueprintSerializer(serializers.HyperlinkedModelSerializer):
class SpecificationUnitBlueprintSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = models.RunBlueprint
model = models.SpecificationUnitBlueprint
fields = '__all__'
class WorkRequestDraftSerializer(serializers.HyperlinkedModelSerializer):
class TaskDraftSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = models.WorkRequestDraft
model = models.TaskDraft
fields = '__all__'
class WorkRequestBlueprintSerializer(serializers.HyperlinkedModelSerializer):
class TaskBlueprintSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = models.WorkRequestBlueprint
model = models.TaskBlueprint
fields = '__all__'
class WorkRequestRelationDraftSerializer(serializers.HyperlinkedModelSerializer):
class TaskRelationDraftSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = models.WorkRequestRelationDraft
model = models.TaskRelationDraft
fields = '__all__'
class WorkRequestRelationBlueprintSerializer(serializers.HyperlinkedModelSerializer):
class TaskRelationBlueprintSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = models.WorkRequestRelationBlueprint
model = models.TaskRelationBlueprint
fields = '__all__'
# ----- JSON
class WorkRequestBlueprintSerializerReactJSONform(serializers.HyperlinkedModelSerializer):
class TaskBlueprintSerializerReactJSONform(serializers.HyperlinkedModelSerializer):
# Create a JSON editor form to replace the simple text field based on the schema in the template that this
# blueprint refers to. If that fails, the JSONField remains a standard text input.
......@@ -175,11 +175,11 @@ class WorkRequestBlueprintSerializerReactJSONform(serializers.HyperlinkedModelSe
class Meta:
model = models.WorkRequestBlueprint
model = models.TaskBlueprint
fields = '__all__'
class WorkRequestBlueprintSerializerJSONeditor(serializers.HyperlinkedModelSerializer):
class TaskBlueprintSerializerJSONeditor(serializers.HyperlinkedModelSerializer):
# Create a JSON editor form to replace the simple text field based on the schema in the template that this
# blueprint refers to. If that fails, the JSONField remains a standard text input.
......@@ -204,12 +204,12 @@ class WorkRequestBlueprintSerializerJSONeditor(serializers.HyperlinkedModelSeria
print('Could not determine schema, hence no fancy JSON form. Expected for list view.')
#requirements_doc = serializers.JSONField(style={'template': 'json_editor_form_2.html', 'template_schema_uri': "http://localhost:8000/work_request_template/2/?format=json"})
#requirements_doc = serializers.JSONField(style={'template': 'json_editor_form_2.html', 'template_schema_uri': "http://localhost:8000/task_template/2/?format=json"})
class Meta:
model = models.WorkRequestBlueprint
model = models.TaskBlueprint
fields = '__all__'
class WorkRequestBlueprintSerializerJSONeditorOnline(serializers.HyperlinkedModelSerializer):
class TaskBlueprintSerializerJSONeditorOnline(serializers.HyperlinkedModelSerializer):
# Create a JSON editor form to replace the simple text field based on the schema in the template that this
# blueprint refers to. If that fails, the JSONField remains a standard text input.
......@@ -234,16 +234,16 @@ class WorkRequestBlueprintSerializerJSONeditorOnline(serializers.HyperlinkedMode
print('Could not determine schema, hence no fancy JSON form. Expected for list view.')
#requirements_doc = serializers.JSONField(style={'template': 'json_editor_form_2.html', 'template_schema_uri': "http://localhost:8000/work_request_template/2/?format=json"})
#requirements_doc = serializers.JSONField(style={'template': 'json_editor_form_2.html', 'template_schema_uri': "http://localhost:8000/task_template/2/?format=json"})
class Meta:
model = models.WorkRequestBlueprint
model = models.TaskBlueprint
fields = '__all__'
class WorkRequestBlueprintJSONSerializer(serializers.HyperlinkedModelSerializer):
class TaskBlueprintJSONSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = models.WorkRequestBlueprint
model = models.TaskBlueprint
fields = ('requirements_doc',)
......@@ -115,8 +115,3 @@ class DataproductArchiveInfoViewSet(viewsets.ModelViewSet):
class DataproductHashViewSet(viewsets.ModelViewSet):
queryset = models.DataproductHash.objects.all()
serializer_class = serializers.DataproductHashSerializer
class TaskRelationBlueprintViewSet(viewsets.ModelViewSet):
queryset = models.TaskRelationBlueprint.objects.all()
serializer_class = serializers.TaskRelationBlueprintSerializer
\ No newline at end of file
......@@ -21,24 +21,24 @@ class DefaultGeneratorTemplateViewSet(viewsets.ModelViewSet):
serializer_class = serializers.DefaultGeneratorTemplateSerializer
class RunTemplateViewSet(viewsets.ModelViewSet):
queryset = models.RunTemplate.objects.all()
serializer_class = serializers.RunTemplateSerializer
class SpecificationUnitTemplateViewSet(viewsets.ModelViewSet):
queryset = models.SpecificationUnitTemplate.objects.all()
serializer_class = serializers.SpecificationUnitTemplateSerializer
class DefaultRunTemplateViewSet(viewsets.ModelViewSet):
queryset = models.DefaultRunTemplate.objects.all()
serializer_class = serializers.DefaultRunTemplateSerializer
class DefaultSpecificationUnitTemplateViewSet(viewsets.ModelViewSet):
queryset = models.DefaultSpecificationUnitTemplate.objects.all()
serializer_class = serializers.DefaultSpecificationUnitTemplateSerializer
class WorkRequestTemplateViewSet(viewsets.ModelViewSet):
queryset = models.WorkRequestTemplate.objects.all()
serializer_class = serializers.WorkRequestTemplateSerializer
class TaskTemplateViewSet(viewsets.ModelViewSet):
queryset = models.TaskTemplate.objects.all()
serializer_class = serializers.TaskTemplateSerializer
class DefaultWorkRequestTemplateViewSet(viewsets.ModelViewSet):
queryset = models.DefaultWorkRequestTemplate.objects.all()
serializer_class = serializers.DefaultWorkRequestTemplateSerializer
class DefaultTaskTemplateViewSet(viewsets.ModelViewSet):
queryset = models.DefaultTaskTemplate.objects.all()
serializer_class = serializers.DefaultTaskTemplateSerializer
class WorkRelationSelectionTemplateViewSet(viewsets.ModelViewSet):
......@@ -71,9 +71,9 @@ class CopyReasonChoiceViewSet(viewsets.ModelViewSet):
serializer_class = serializers.CopyReasonChoiceSerializer
class WorkIORoleViewSet(viewsets.ModelViewSet):
queryset = models.WorkIORole.objects.all()
serializer_class = serializers.WorkIORoleSerializer
class TaskConnectorsViewSet(viewsets.ModelViewSet):
queryset = models.TaskConnectors.objects.all()
serializer_class = serializers.TaskConnectorsSerializer
class CycleViewSet(viewsets.ModelViewSet):
......@@ -86,62 +86,62 @@ class ProjectViewSet(viewsets.ModelViewSet):
serializer_class = serializers.ProjectSerializer
class RunSetViewSet(viewsets.ModelViewSet):
queryset = models.RunSet.objects.all()
serializer_class = serializers.RunSetSerializer
class SpecificationSetViewSet(viewsets.ModelViewSet):
queryset = models.SpecificationSet.objects.all()
serializer_class = serializers.SpecificationSetSerializer
class RunDraftViewSet(viewsets.ModelViewSet):
queryset = models.RunDraft.objects.all()
serializer_class = serializers.RunDraftSerializer
class SpecificationUnitDraftViewSet(viewsets.ModelViewSet):
queryset = models.SpecificationUnitDraft.objects.all()
serializer_class = serializers.SpecificationUnitDraftSerializer
class RunBlueprintViewSet(viewsets.ModelViewSet):
queryset = models.RunBlueprint.objects.all()
serializer_class = serializers.RunBlueprintSerializer
class SpecificationUnitBlueprintViewSet(viewsets.ModelViewSet):
queryset = models.SpecificationUnitBlueprint.objects.all()
serializer_class = serializers.SpecificationUnitBlueprintSerializer
class WorkRequestDraftViewSet(viewsets.ModelViewSet):
queryset = models.WorkRequestDraft.objects.all()
serializer_class = serializers.WorkRequestDraftSerializer
class TaskDraftViewSet(viewsets.ModelViewSet):
queryset = models.TaskDraft.objects.all()
serializer_class = serializers.TaskDraftSerializer
class WorkRequestBlueprintViewSet(viewsets.ModelViewSet):
queryset = models.WorkRequestBlueprint.objects.all()
serializer_class = serializers.WorkRequestBlueprintSerializer
class TaskBlueprintViewSet(viewsets.ModelViewSet):
queryset = models.TaskBlueprint.objects.all()
serializer_class = serializers.TaskBlueprintSerializer
class WorkRequestRelationDraftViewSet(viewsets.ModelViewSet):
queryset = models.WorkRequestRelationDraft.objects.all()
serializer_class = serializers.WorkRequestRelationDraftSerializer
class TaskRelationDraftViewSet(viewsets.ModelViewSet):
queryset = models.TaskRelationDraft.objects.all()
serializer_class = serializers.TaskRelationDraftSerializer
class WorkRequestRelationBlueprintViewSet(viewsets.ModelViewSet):
queryset = models.WorkRequestRelationBlueprint.objects.all()
serializer_class = serializers.WorkRequestRelationBlueprintSerializer
class TaskRelationBlueprintViewSet(viewsets.ModelViewSet):
queryset = models.TaskRelationBlueprint.objects.all()
serializer_class = serializers.TaskRelationBlueprintSerializer
# --- JSON
class WorkRequestBlueprintViewSetReactJSONform(viewsets.ModelViewSet):
queryset = models.WorkRequestBlueprint.objects.all()
serializer_class = serializers.WorkRequestBlueprintSerializerReactJSONform
class TaskBlueprintViewSetReactJSONform(viewsets.ModelViewSet):
queryset = models.TaskBlueprint.objects.all()
serializer_class = serializers.TaskBlueprintSerializerReactJSONform
class WorkRequestBlueprintViewSetJSONeditor(viewsets.ModelViewSet):
queryset = models.WorkRequestBlueprint.objects.all()
serializer_class = serializers.WorkRequestBlueprintSerializerJSONeditor
class TaskBlueprintViewSetJSONeditor(viewsets.ModelViewSet):
queryset = models.TaskBlueprint.objects.all()
serializer_class = serializers.TaskBlueprintSerializerJSONeditor
class WorkRequestBlueprintViewSetJSONeditorOnline(viewsets.ModelViewSet):
queryset = models.WorkRequestBlueprint.objects.all()
serializer_class = serializers.WorkRequestBlueprintSerializerJSONeditorOnline
class TaskBlueprintViewSetJSONeditorOnline(viewsets.ModelViewSet):
queryset = models.TaskBlueprint.objects.all()
serializer_class = serializers.TaskBlueprintSerializerJSONeditorOnline
# # todo: this is experimental / for demo purposes. Remove or make functional.
# class JSONEditorViewSet(viewsets.ModelViewSet):
# renderer_classes = [TemplateHTMLRenderer]
# template_name = 'react_jsonschema_form.html'
# queryset = models.WorkRequestBlueprint.objects.all()
# serializer_class = serializers.WorkRequestBlueprintJSONSerializer
# queryset = models.TaskBlueprint.objects.all()
# serializer_class = serializers.TaskBlueprintJSONSerializer
......@@ -51,25 +51,25 @@ router.register(r'copy_reason_choice', viewsets.CopyReasonChoiceViewSet)
# templates
router.register(r'generator_template', viewsets.GeneratorTemplateViewSet)
router.register(r'run_template', viewsets.RunTemplateViewSet)
router.register(r'work_request_template', viewsets.WorkRequestTemplateViewSet)
router.register(r'specification_unit_template', viewsets.SpecificationUnitTemplateViewSet)
router.register(r'task_template', viewsets.TaskTemplateViewSet)
router.register(r'work_relation_selection_template', viewsets.WorkRelationSelectionTemplateViewSet)
router.register(r'work_io_role', viewsets.WorkIORoleViewSet)
router.register(r'task_connectors', viewsets.TaskConnectorsViewSet)
router.register(r'default_generator_template', viewsets.DefaultGeneratorTemplateViewSet)
router.register(r'default_run_template', viewsets.DefaultRunTemplateViewSet)
router.register(r'default_work_request_template', viewsets.DefaultWorkRequestTemplateViewSet)
router.register(r'default_specification_unit_template', viewsets.DefaultSpecificationUnitTemplateViewSet)
router.register(r'default_task_template', viewsets.DefaultTaskTemplateViewSet)
router.register(r'default_work_relation_selection_template', viewsets.DefaultWorkRelationSelectionTemplateViewSet)
# instances
router.register(r'cycle', viewsets.CycleViewSet)
router.register(r'project', viewsets.ProjectViewSet)
router.register(r'run_set', viewsets.RunSetViewSet)
router.register(r'run_draft', viewsets.RunDraftViewSet)
router.register(r'run_blueprint', viewsets.RunBlueprintViewSet)
router.register(r'work_request_draft', viewsets.WorkRequestDraftViewSet)
router.register(r'work_request_blueprint', viewsets.WorkRequestBlueprintViewSet)
router.register(r'work_request_relation_draft', viewsets.WorkRequestRelationDraftViewSet)
router.register(r'work_request_relation_blueprint', viewsets.WorkRequestRelationBlueprintViewSet)
router.register(r'specification_set', viewsets.SpecificationSetViewSet)
router.register(r'specification_unit_draft', viewsets.SpecificationUnitDraftViewSet)
router.register(r'specification_unit_blueprint', viewsets.SpecificationUnitBlueprintViewSet)
router.register(r'task_draft', viewsets.TaskDraftViewSet)
router.register(r'task_blueprint', viewsets.TaskBlueprintViewSet)
router.register(r'task_relation_draft', viewsets.TaskRelationDraftViewSet)
router.register(r'task_relation_blueprint', viewsets.TaskRelationBlueprintViewSet)
# SCHEDULING
......@@ -108,9 +108,9 @@ router.register(r'task_relation_blueprint', viewsets.TaskRelationBlueprintViewSe
# ---
# JSON
router.register(r'work_request_blueprint_A', viewsets.WorkRequestBlueprintViewSetJSONeditor)
router.register(r'work_request_blueprint_B', viewsets.WorkRequestBlueprintViewSetReactJSONform)
router.register(r'work_request_blueprint_C', viewsets.WorkRequestBlueprintViewSetJSONeditorOnline)
router.register(r'task_blueprint_A', viewsets.TaskBlueprintViewSetJSONeditor)
router.register(r'task_blueprint_B', viewsets.TaskBlueprintViewSetReactJSONform)
router.register(r'task_blueprint_C', viewsets.TaskBlueprintViewSetJSONeditorOnline)
#router.register(r'json_editor', viewsets.JSONEditorViewSet)
urlpatterns.extend(router.urls)
......@@ -119,47 +119,47 @@ def _dummy_subtask_template():
return models.SubtaskTemplate.objects.create(**dummy_template_details)
def _dummy_run_set(project):
dummy_run_set_details = {"name": 'dummy',
"description": "Dummy run set",
def _dummy_specification_set(project):
dummy_specification_set_details = {"name": 'dummy',
"description": "Dummy specification unit set",
"tags": ["DUMMY"],
"generator_parameters_doc": "{}",
"generator_doc": "{}",
"project": project,
"generator_template": None}
return models.RunSet.objects.create(**dummy_run_set_details)
return models.SpecificationSet.objects.create(**dummy_specification_set_details)
def _dummy_run_template():
dummy_run_template_details = {"name": "dummy",
"description": 'Dummy run template',
def _dummy_specification_unit_template():
dummy_specification_unit_template_details = {"name": "dummy",
"description": 'Dummy specification unit template',
"version": 'v0.314159265359',
"schema": {"mykey": "my value"},
"tags": ["DUMMY"]}
return models.RunTemplate.objects.create(**dummy_run_template_details)
return models.RunTemplate.objects.create(**dummy_specification_unit_template_details)
def _dummy_run_draft(run_set, template):
dummy_run_draft_details = {"name": 'dummy',
"description": "Dummy run draft",
def _dummy_specification_unit_draft(specification_set, template):
dummy_specification_unit_draft_details = {"name": 'dummy',
"description": "Dummy specification_unit draft",
"tags": ["DUMMY"],
"requirements_doc": "{}",
"copy_reason": models.CopyReasonChoice.objects.get(value='template'),
"generator_param": "para",
"generator_instance_doc": "para",
"copies": None,
"run_set": run_set,
"specification_set": specification_set,
"generator_source": None,
"template": template}
return models.RunDraft.objects.create(**dummy_run_draft_details)
return models.RunDraft.objects.create(**dummy_specification_unit_draft_details)
def _dummy_run_blueprint(draft, template):
def _dummy_specification_unit_blueprint(draft, template):
dummy_run_blueprint_details = {"name": 'dummy',
"description": "Dummy run blueprint",
dummy_specification_unit_blueprint_details = {"name": 'dummy',
"description": "Dummy specification_unit blueprint",
"tags": ["DUMMY"],
"requirements_doc": "{}",
"do_cancel": False,
......@@ -167,47 +167,47 @@ def _dummy_run_blueprint(draft, template):
"template": template}
return models.RunBlueprint.objects.create(**dummy_run_blueprint_details)
return models.RunBlueprint.objects.create(**dummy_specification_unit_blueprint_details)
def _dummy_work_request_template():
def _dummy_task_template():
dummy_work_request_template_details = {"name": "dummy",
dummy_task_template_details = {"name": "dummy",
"description": 'Dummy work request template',
"validation_code_js": "",
"version": 'v0.314159265359',
"schema": {"mykey": "my value"},
"tags": ["DUMMY"]}
return models.WorkRequestTemplate.objects.create(**dummy_work_request_template_details)
return models.TaskTemplate.objects.create(**dummy_task_template_details)
def _dummy_work_request_draft(run_draft, template):
def _dummy_task_draft(specification_unit_draft, template):
dummy_work_request_draft_details = {"name": 'dummy',
dummy_task_draft_details = {"name": 'dummy',
"description": "Dummy work request draft",
"tags": ["DUMMY"],
"requirements_doc": "{}",
"copy_reason": models.CopyReasonChoice.objects.get(value='template'),
"copies": None,
"run_draft": run_draft,
"specification_unit_draft": specification_unit_draft,
"template": template}
return models.WorkRequestDraft.objects.create(**dummy_work_request_draft_details)
return models.TaskDraft.objects.create(**dummy_task_draft_details)
def _dummy_work_request_blueprint(draft, template, run_blueprint):
def _dummy_task_blueprint(draft, template, specification_unit_blueprint):
dummy_work_request_blueprint_details = {"name": 'dummy',
dummy_task_blueprint_details = {"name": 'dummy',
"description": "Dummy work request blueprint",
"tags": ["DUMMY"],
"requirements_doc": "{}",
"do_cancel": False,
"draft": draft,
"template": template,
"run_blueprint": run_blueprint}
"specification_unit_blueprint": specification_unit_blueprint}
return models.WorkRequestBlueprint.objects.create(**dummy_work_request_blueprint_details)
return models.TaskBlueprint.objects.create(**dummy_task_blueprint_details)
def get_subtask_details_from_momdb(project_mom2id, project):
......@@ -245,7 +245,7 @@ def get_subtask_details_from_momdb(project_mom2id, project):
"state": None, # mandatory
"requested_state": None, # mandatory
"specification": "{}",
"work_request_blueprint": None, # optional, but required for project reference
"task_blueprint": None, # optional, but required for project reference
"template": None, # mandatory
"tags": ["migrated_from_MoM"]}
......@@ -293,28 +293,28 @@ def get_subtask_details_from_momdb(project_mom2id, project):
# todo: the following entries are needed to relate a task to it's project.
# todo: we should substitute the dummy items by items that reflect the actual task details
# run set
run_set = _dummy_run_set(project)
# specification set
specification_set = _dummy_specification_set(project)
# run template
run_template = _dummy_run_template()
# specification unit template
specification_unit_template = _dummy_specification_unit_template()
# run draft
run_draft = _dummy_run_draft(run_set, run_template)
# specification unit draft
specification_unit_draft = _dummy_specification_unit_draft(specification_set, specification_unit_template)
# run blueprint
run_blueprint = _dummy_run_blueprint(run_draft, run_template)
# specification unit blueprint
specification_unit_blueprint = _dummy_specification_unit_blueprint(specification_unit_draft, specification_unit_template)
# work request template
work_request_template = _dummy_work_request_template()
task_template = _dummy_task_template()
# work request draft
work_request_draft = _dummy_work_request_draft(run_draft, work_request_template)
task_draft = _dummy_task_draft(specification_unit_draft, task_template)
# work request blueprint
details['work_request_blueprint'] = _dummy_work_request_blueprint(work_request_draft,
work_request_template,
run_blueprint)
details['task_blueprint'] = _dummy_task_blueprint(task_draft,
task_template,
specification_unit_blueprint)
# ----------------
# add task mom2id and its details to return dict
......
......@@ -150,7 +150,7 @@ const schema = {
"relative_starttime": {
"type": "number",
"title": "Relative starttime (seconds)",
"description": "Starttime with respect to other observations in this run",
"description": "Starttime with respect to other observations in this specification unit",
"default": 0,
"minimum": 0
},
......
......@@ -24,7 +24,7 @@ import rest_framework.test
from lsmr.lsmrapp.populate import populate_choices
from lsmr.lsmrapp import models
from django.db.utils import IntegrityError
from t_lsmrapp_specification_django import assertDataWithUrls, WorkRequestBlueprintTest
from t_lsmrapp_specification_django import assertDataWithUrls, TaskBlueprintTest, TaskRelationBlueprintTest
from datetime import datetime # use this to create timezone-aware datetime objects: from django.utils import timezone
from django.contrib.auth.models import User
......@@ -352,12 +352,12 @@ class SubtaskInputTest(rest_framework.test.APITransactionTestCase):
sct = SubtaskConnectorTest()
sct.setUp(populate=False)
trbt = TaskRelationBlueprintTest()
trbt.setUp(populate=False)
# test data
self.test_data_1 = {"subtask": models.Subtask.objects.create(**st.test_data_1),
"task_relation_blueprint": models.TaskRelationBlueprint.objects.create(tags=[]),
#**TaskRelationBlueprintTest.test_data_1), # todo: after specification model update
"task_relation_blueprint": models.TaskRelationBlueprint.objects.create(**trbt.test_data_1),
"connector": models.SubtaskConnector.objects.create(**sct.test_data_1),
"producer": models.SubtaskOutput.objects.create(**sot.test_data_1),
#"dataproducts": models.Dataproduct.objects.create(**dpt.test_data_1),
......@@ -367,8 +367,7 @@ class SubtaskInputTest(rest_framework.test.APITransactionTestCase):
"tags":[]}
self.test_data_2 = {"subtask": models.Subtask.objects.create(**st.test_data_2),
"task_relation_blueprint": models.TaskRelationBlueprint.objects.create(tags=[]),
#**TaskRelationBlueprintTest.test_data_1), # todo: after specification model update
"task_relation_blueprint": models.TaskRelationBlueprint.objects.create(**trbt.test_data_2),
"connector": models.SubtaskConnector.objects.create(**sct.test_data_2),
"producer": models.SubtaskOutput.objects.create(**sot.test_data_2),
#"dataproducts": models.Dataproduct.objects.create(**dpt.test_data_2),
......@@ -470,7 +469,7 @@ class SubtaskTest(rest_framework.test.APITransactionTestCase):