Adds test for updating workflow spec
This commit is contained in:
parent
a98251237b
commit
a0c35fe8cf
|
@ -2,7 +2,7 @@ import json
|
|||
|
||||
from crc import session
|
||||
from crc.models.file import FileModel
|
||||
from crc.models.workflow import WorkflowSpecModel, WorkflowSpecModelSchema, WorkflowModel
|
||||
from crc.models.workflow import WorkflowSpecModel, WorkflowSpecModelSchema, WorkflowModel, WorkflowSpecCategoryModel
|
||||
from tests.base_test import BaseTest
|
||||
|
||||
|
||||
|
@ -46,6 +46,32 @@ class TestWorkflowSpec(BaseTest):
|
|||
api_spec = WorkflowSpecModelSchema().load(json_data, session=session)
|
||||
self.assertEqual(db_spec, api_spec)
|
||||
|
||||
def test_update_workflow_specification(self):
|
||||
self.load_example_data()
|
||||
|
||||
category = WorkflowSpecCategoryModel(id=0, name='trap', display_name="It's a trap!")
|
||||
session.add(category)
|
||||
session.commit()
|
||||
|
||||
db_spec_before: WorkflowSpecModel = session.query(WorkflowSpecModel).first()
|
||||
spec_id = db_spec_before.id
|
||||
self.assertIsNone(db_spec_before.workflow_spec_category_id)
|
||||
|
||||
db_spec_before.workflow_spec_category_id = 0
|
||||
rv = self.app.put('/v1.0/workflow-specification/%s' % spec_id,
|
||||
content_type="application/json",
|
||||
headers=self.logged_in_headers(),
|
||||
data=json.dumps(WorkflowSpecModelSchema().dump(db_spec_before)))
|
||||
self.assert_success(rv)
|
||||
json_data = json.loads(rv.get_data(as_text=True))
|
||||
api_spec = WorkflowSpecModelSchema().load(json_data, session=session)
|
||||
self.assertEqual(db_spec_before, api_spec)
|
||||
|
||||
db_spec_after: WorkflowSpecModel = session.query(WorkflowSpecModel).filter_by(id=spec_id).first()
|
||||
self.assertIsNotNone(db_spec_after.workflow_spec_category_id)
|
||||
self.assertIsNotNone(db_spec_after.workflow_spec_category)
|
||||
self.assertEqual(db_spec_after.workflow_spec_category.display_name, category.display_name)
|
||||
|
||||
def test_delete_workflow_specification(self):
|
||||
self.load_example_data()
|
||||
spec_id = 'random_fact'
|
||||
|
|
Loading…
Reference in New Issue