Changes to tests after removing `name` column from `workflow_spec` and `workflow_spec_category` tables.
This commit is contained in:
parent
572ca1db6b
commit
da894219c5
|
@ -28,7 +28,7 @@ class TestFilesApi(BaseTest):
|
|||
self.assertEqual(5, len(json_data))
|
||||
files = FileModelSchema(many=True).load(json_data, session=session)
|
||||
file_names = [f.name for f in files]
|
||||
self.assertTrue("%s.bpmn" % spec.name in file_names)
|
||||
self.assertTrue("%s.bpmn" % spec.id in file_names)
|
||||
|
||||
def test_list_multiple_files_for_workflow_spec(self):
|
||||
self.load_example_data()
|
||||
|
|
|
@ -67,12 +67,11 @@ class TestStudyApi(BaseTest):
|
|||
# Categories are read only, so switching to sub-scripting here.
|
||||
# This assumes there is one test category set up in the example data.
|
||||
category = study.categories[0]
|
||||
self.assertEqual("test_category", category['name'])
|
||||
self.assertEqual("Test Category", category['display_name'])
|
||||
self.assertEqual(False, category['admin'])
|
||||
self.assertEqual(1, len(category["workflows"]))
|
||||
workflow = category["workflows"][0]
|
||||
self.assertEqual("random_fact", workflow["name"])
|
||||
self.assertEqual("random_fact", workflow["id"])
|
||||
self.assertEqual("optional", workflow["state"])
|
||||
self.assertEqual("not_started", workflow["status"])
|
||||
self.assertEqual(0, workflow["total_tasks"])
|
||||
|
|
|
@ -26,7 +26,7 @@ class TestStudyService(BaseTest):
|
|||
|
||||
# Assure some basic models are in place, This is a damn mess. Our database models need an overhaul to make
|
||||
# this easier - better relationship modeling is now critical.
|
||||
cat = WorkflowSpecCategoryModel(name="approvals", display_name="Approvals", display_order=0)
|
||||
cat = WorkflowSpecCategoryModel(id=None, display_name="Approvals", display_order=0)
|
||||
db.session.add(cat)
|
||||
db.session.commit()
|
||||
self.load_test_spec("top_level_workflow", master_spec=True, category_id=cat.id)
|
||||
|
@ -80,7 +80,7 @@ class TestStudyService(BaseTest):
|
|||
self.assertEqual(0, workflow.completed_tasks)
|
||||
|
||||
# Initialize the Workflow with the workflow processor.
|
||||
workflow_model = db.session.query(WorkflowModel).filter(WorkflowModel.id == workflow.id).first()
|
||||
workflow_model = db.session.query(WorkflowModel).filter(WorkflowModel.workflow_spec_id == workflow.id).first()
|
||||
processor = WorkflowProcessor(workflow_model)
|
||||
processor.do_engine_steps()
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class TestAutoSetPrimaryBPMN(BaseTest):
|
|||
self.load_example_data()
|
||||
category_id = session.query(WorkflowSpecCategoryModel).first().id
|
||||
# Add a workflow spec
|
||||
spec = WorkflowSpecModel(id='make_cookies', name='make_cookies', display_name='Cooooookies',
|
||||
spec = WorkflowSpecModel(id='make_cookies', display_name='Cooooookies',
|
||||
description='Om nom nom delicious cookies', category_id=category_id,
|
||||
standalone=False)
|
||||
rv = self.app.post('/v1.0/workflow-specification',
|
||||
|
|
|
@ -94,7 +94,7 @@ class TestTasksApi(BaseTest):
|
|||
json_data = json.loads(rv.get_data(as_text=True))
|
||||
tasks = TaskEventSchema(many=True).load(json_data)
|
||||
self.assertEqual(1, len(tasks))
|
||||
self.assertEqual(workflow.id, tasks[0]['workflow']['id'])
|
||||
self.assertEqual(workflow.workflow_spec_id, tasks[0]['workflow']['id'])
|
||||
self.assertEqual(workflow.study.id, tasks[0]['study']['id'])
|
||||
self.assertEqual("Test Workflows", tasks[0]['workflow']['category_display_name'])
|
||||
|
||||
|
@ -102,10 +102,10 @@ class TestTasksApi(BaseTest):
|
|||
# You have a task called "Approval" to be completed in the "Supervisor Approval" workflow
|
||||
# for the study 'Why dogs are stinky' managed by user "Jane Smith (js42x)",
|
||||
# please check here to complete the task.
|
||||
# Display name isn't set in the tests, so just checking name, but the full workflow details are included.
|
||||
# Just checking display_name for workflow, but the full workflow details are included.
|
||||
# I didn't delve into the full user details to keep things decoupled from ldap, so you just get the
|
||||
# uid back, but could query to get the full entry.
|
||||
self.assertEqual("roles", tasks[0]['workflow']['name'])
|
||||
self.assertEqual("Roles", tasks[0]['workflow']['display_name'])
|
||||
self.assertEqual("Beer consumption in the bipedal software engineer", tasks[0]['study']['title'])
|
||||
self.assertEqual("lje5u", tasks[0]['study']['user_uid'])
|
||||
|
||||
|
|
|
@ -348,7 +348,7 @@ class TestWorkflowProcessor(BaseTest):
|
|||
|
||||
study = session.query(StudyModel).first()
|
||||
workflow_spec_model = db.session.query(WorkflowSpecModel).\
|
||||
filter(WorkflowSpecModel.name == "top_level_workflow").first()
|
||||
filter(WorkflowSpecModel.id == "top_level_workflow").first()
|
||||
self.assertIsNotNone(workflow_spec_model)
|
||||
|
||||
processor = self.get_processor(study, workflow_spec_model)
|
||||
|
|
|
@ -22,7 +22,7 @@ class TestWorkflowReset(BaseTest):
|
|||
second_task = workflow_api.next_task
|
||||
self.assertEqual('Task_GetAge', second_task.name)
|
||||
|
||||
ResetWorkflow().do_task(second_task, workflow.study_id, workflow.id, workflow_name='two_user_tasks')
|
||||
ResetWorkflow().do_task(second_task, workflow.study_id, workflow.id, reset_id='two_user_tasks')
|
||||
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
task = workflow_api.next_task
|
||||
|
@ -42,4 +42,4 @@ class TestWorkflowReset(BaseTest):
|
|||
first_task = workflow_api.next_task
|
||||
|
||||
with self.assertRaises(ApiError):
|
||||
ResetWorkflow().do_task(first_task, workflow.study_id, workflow.id, workflow_name='bad_workflow_name')
|
||||
ResetWorkflow().do_task(first_task, workflow.study_id, workflow.id, reset_id='bad_workflow_name')
|
||||
|
|
|
@ -29,7 +29,7 @@ class TestWorkflowSpec(BaseTest):
|
|||
num_before = session.query(WorkflowSpecModel).count()
|
||||
category_id = session.query(WorkflowSpecCategoryModel).first().id
|
||||
category_count = session.query(WorkflowSpecModel).filter_by(category_id=category_id).count()
|
||||
spec = WorkflowSpecModel(id='make_cookies', name='make_cookies', display_name='Cooooookies',
|
||||
spec = WorkflowSpecModel(id='make_cookies', display_name='Cooooookies',
|
||||
description='Om nom nom delicious cookies', category_id=category_id,
|
||||
standalone=False)
|
||||
rv = self.app.post('/v1.0/workflow-specification',
|
||||
|
@ -58,7 +58,7 @@ class TestWorkflowSpec(BaseTest):
|
|||
self.load_example_data()
|
||||
|
||||
category_id = 99
|
||||
category = WorkflowSpecCategoryModel(id=category_id, name='trap', display_name="It's a trap!", display_order=0)
|
||||
category = WorkflowSpecCategoryModel(id=category_id, display_name="It's a trap!", display_order=0)
|
||||
session.add(category)
|
||||
session.commit()
|
||||
|
||||
|
@ -107,13 +107,13 @@ class TestWorkflowSpec(BaseTest):
|
|||
def test_display_order_after_delete_spec(self):
|
||||
self.load_example_data()
|
||||
workflow_spec_category = session.query(WorkflowSpecCategoryModel).first()
|
||||
spec_model_1 = WorkflowSpecModel(id='test_spec_1', name='test_spec_1', display_name='Test Spec 1',
|
||||
spec_model_1 = WorkflowSpecModel(id='test_spec_1', display_name='Test Spec 1',
|
||||
description='Test Spec 1 Description', category_id=workflow_spec_category.id,
|
||||
display_order=1, standalone=False)
|
||||
spec_model_2 = WorkflowSpecModel(id='test_spec_2', name='test_spec_2', display_name='Test Spec 2',
|
||||
spec_model_2 = WorkflowSpecModel(id='test_spec_2', display_name='Test Spec 2',
|
||||
description='Test Spec 2 Description', category_id=workflow_spec_category.id,
|
||||
display_order=2, standalone=False)
|
||||
spec_model_3 = WorkflowSpecModel(id='test_spec_3', name='test_spec_3', display_name='Test Spec 3',
|
||||
spec_model_3 = WorkflowSpecModel(id='test_spec_3', display_name='Test Spec 3',
|
||||
description='Test Spec 3 Description', category_id=workflow_spec_category.id,
|
||||
display_order=3, standalone=False)
|
||||
session.add(spec_model_1)
|
||||
|
@ -159,7 +159,6 @@ class TestWorkflowSpec(BaseTest):
|
|||
count = session.query(WorkflowSpecCategoryModel).count()
|
||||
category = WorkflowSpecCategoryModel(
|
||||
id=count,
|
||||
name='another_test_category',
|
||||
display_name='Another Test Category',
|
||||
display_order=0
|
||||
)
|
||||
|
@ -169,18 +168,18 @@ class TestWorkflowSpec(BaseTest):
|
|||
data=json.dumps(WorkflowSpecCategoryModelSchema().dump(category))
|
||||
)
|
||||
self.assert_success(rv)
|
||||
result = session.query(WorkflowSpecCategoryModel).filter(WorkflowSpecCategoryModel.name=='another_test_category').first()
|
||||
result = session.query(WorkflowSpecCategoryModel).filter(WorkflowSpecCategoryModel.id==count).first()
|
||||
self.assertEqual('Another Test Category', result.display_name)
|
||||
self.assertEqual(count, result.id)
|
||||
|
||||
def test_update_workflow_spec_category(self):
|
||||
self.load_example_data()
|
||||
category = session.query(WorkflowSpecCategoryModel).first()
|
||||
category_name_before = category.name
|
||||
new_category_name = category_name_before + '_asdf'
|
||||
self.assertNotEqual(category_name_before, new_category_name)
|
||||
display_name_before = category.display_name
|
||||
new_display_name = display_name_before + '_asdf'
|
||||
self.assertNotEqual(display_name_before, new_display_name)
|
||||
|
||||
category.name = new_category_name
|
||||
category.display_name = new_display_name
|
||||
|
||||
rv = self.app.put(f'/v1.0/workflow-specification-category/{category.id}',
|
||||
content_type="application/json",
|
||||
|
@ -188,25 +187,22 @@ class TestWorkflowSpec(BaseTest):
|
|||
data=json.dumps(WorkflowSpecCategoryModelSchema().dump(category)))
|
||||
self.assert_success(rv)
|
||||
json_data = json.loads(rv.get_data(as_text=True))
|
||||
self.assertEqual(new_category_name, json_data['name'])
|
||||
self.assertEqual(new_display_name, json_data['display_name'])
|
||||
|
||||
def test_delete_workflow_spec_category(self):
|
||||
self.load_example_data()
|
||||
category_model_1 = WorkflowSpecCategoryModel(
|
||||
id=1,
|
||||
name='test_category_1',
|
||||
display_name='Test Category 1',
|
||||
display_order=1
|
||||
)
|
||||
category_model_2 = WorkflowSpecCategoryModel(
|
||||
id=2,
|
||||
name='test_category_2',
|
||||
display_name='Test Category 2',
|
||||
display_order=2
|
||||
)
|
||||
category_model_3 = WorkflowSpecCategoryModel(
|
||||
id=3,
|
||||
name='test_category_3',
|
||||
display_name='Test Category 3',
|
||||
display_order=3
|
||||
)
|
||||
|
@ -225,7 +221,7 @@ class TestWorkflowSpec(BaseTest):
|
|||
def test_add_library_with_category_id(self):
|
||||
self.load_example_data()
|
||||
category_id = session.query(WorkflowSpecCategoryModel).first().id
|
||||
spec = WorkflowSpecModel(id='test_spec', name='test_spec', display_name='Test Spec',
|
||||
spec = WorkflowSpecModel(id='test_spec', display_name='Test Spec',
|
||||
description='Library with a category id', category_id=category_id,
|
||||
standalone=False, library=True)
|
||||
rv = self.app.post('/v1.0/workflow-specification',
|
||||
|
|
|
@ -13,19 +13,16 @@ class TestWorkflowSpecCategoryReorder(BaseTest):
|
|||
def _load_test_categories():
|
||||
category_model_1 = WorkflowSpecCategoryModel(
|
||||
id=1,
|
||||
name='test_category_1',
|
||||
display_name='Test Category 1',
|
||||
display_order=1
|
||||
)
|
||||
category_model_2 = WorkflowSpecCategoryModel(
|
||||
id=2,
|
||||
name='test_category_2',
|
||||
display_name='Test Category 2',
|
||||
display_order=2
|
||||
)
|
||||
category_model_3 = WorkflowSpecCategoryModel(
|
||||
id=3,
|
||||
name='test_category_3',
|
||||
display_name='Test Category 3',
|
||||
display_order=3
|
||||
)
|
||||
|
|
|
@ -10,21 +10,21 @@ class TestWorkflowSpecReorder(BaseTest):
|
|||
|
||||
def _load_sample_workflow_specs(self):
|
||||
workflow_spec_category = session.query(WorkflowSpecCategoryModel).first()
|
||||
spec_model_1 = WorkflowSpecModel(id='test_spec_1', name='test_spec_1', display_name='Test Spec 1',
|
||||
spec_model_1 = WorkflowSpecModel(id='test_spec_1', display_name='Test Spec 1',
|
||||
description='Test Spec 1 Description', category_id=workflow_spec_category.id,
|
||||
standalone=False)
|
||||
rv_1 = self.app.post('/v1.0/workflow-specification',
|
||||
headers=self.logged_in_headers(),
|
||||
content_type="application/json",
|
||||
data=json.dumps(WorkflowSpecModelSchema().dump(spec_model_1)))
|
||||
spec_model_2 = WorkflowSpecModel(id='test_spec_2', name='test_spec_2', display_name='Test Spec 2',
|
||||
spec_model_2 = WorkflowSpecModel(id='test_spec_2', display_name='Test Spec 2',
|
||||
description='Test Spec 2 Description', category_id=workflow_spec_category.id,
|
||||
standalone=False)
|
||||
rv_2 = self.app.post('/v1.0/workflow-specification',
|
||||
headers=self.logged_in_headers(),
|
||||
content_type="application/json",
|
||||
data=json.dumps(WorkflowSpecModelSchema().dump(spec_model_2)))
|
||||
spec_model_3 = WorkflowSpecModel(id='test_spec_3', name='test_spec_3', display_name='Test Spec 3',
|
||||
spec_model_3 = WorkflowSpecModel(id='test_spec_3', display_name='Test Spec 3',
|
||||
description='Test Spec 3 Description', category_id=workflow_spec_category.id,
|
||||
standalone=False)
|
||||
rv_3 = self.app.post('/v1.0/workflow-specification',
|
||||
|
@ -37,11 +37,11 @@ class TestWorkflowSpecReorder(BaseTest):
|
|||
self.load_example_data()
|
||||
rv_1, rv_2, rv_3 = self._load_sample_workflow_specs()
|
||||
self.assertEqual(1, rv_1.json['display_order'])
|
||||
self.assertEqual('test_spec_1', rv_1.json['name'])
|
||||
self.assertEqual('test_spec_1', rv_1.json['id'])
|
||||
self.assertEqual(2, rv_2.json['display_order'])
|
||||
self.assertEqual('test_spec_2', rv_2.json['name'])
|
||||
self.assertEqual('test_spec_2', rv_2.json['id'])
|
||||
self.assertEqual(3, rv_3.json['display_order'])
|
||||
self.assertEqual('test_spec_3', rv_3.json['name'])
|
||||
self.assertEqual('test_spec_3', rv_3.json['id'])
|
||||
|
||||
def test_workflow_spec_reorder_bad_direction(self):
|
||||
self.load_example_data()
|
||||
|
@ -163,13 +163,13 @@ class TestWorkflowSpecReorder(BaseTest):
|
|||
# but it is
|
||||
# test_spec_1, random_fact, test_spec_2, test_spec_3
|
||||
self.assertEqual(1, bad_orders[0].display_order)
|
||||
self.assertEqual('test_spec_1', bad_orders[0].name)
|
||||
self.assertEqual('test_spec_1', bad_orders[0].id)
|
||||
self.assertEqual(1, bad_orders[1].display_order)
|
||||
self.assertEqual('random_fact', bad_orders[1].name)
|
||||
self.assertEqual('random_fact', bad_orders[1].id)
|
||||
self.assertEqual(1, bad_orders[2].display_order)
|
||||
self.assertEqual('test_spec_2', bad_orders[2].name)
|
||||
self.assertEqual('test_spec_2', bad_orders[2].id)
|
||||
self.assertEqual(3, bad_orders[3].display_order)
|
||||
self.assertEqual('test_spec_3', bad_orders[3].name)
|
||||
self.assertEqual('test_spec_3', bad_orders[3].id)
|
||||
|
||||
# Move test_spec_2 up
|
||||
# This should cause a cleanup of the bad display_order numbers
|
||||
|
@ -179,11 +179,11 @@ class TestWorkflowSpecReorder(BaseTest):
|
|||
# After moving 2 up, the order should be
|
||||
# test_spec_1, test_spec_2, random_fact, test_spec_3
|
||||
# Make sure we have good display_order numbers too
|
||||
self.assertEqual('test_spec_1', rv.json[0]['name'])
|
||||
self.assertEqual('test_spec_1', rv.json[0]['id'])
|
||||
self.assertEqual(0, rv.json[0]['display_order'])
|
||||
self.assertEqual('test_spec_2', rv.json[1]['name'])
|
||||
self.assertEqual('test_spec_2', rv.json[1]['id'])
|
||||
self.assertEqual(1, rv.json[1]['display_order'])
|
||||
self.assertEqual('random_fact', rv.json[2]['name'])
|
||||
self.assertEqual('random_fact', rv.json[2]['id'])
|
||||
self.assertEqual(2, rv.json[2]['display_order'])
|
||||
self.assertEqual('test_spec_3', rv.json[3]['name'])
|
||||
self.assertEqual('test_spec_3', rv.json[3]['id'])
|
||||
self.assertEqual(3, rv.json[3]['display_order'])
|
||||
|
|
|
@ -163,7 +163,6 @@ class TestWorkflowSpecValidation(BaseTest):
|
|||
|
||||
# workflow spec to validate
|
||||
spec_model = WorkflowSpecModel(id='data_security_plan',
|
||||
name='data_security_plan',
|
||||
display_name='Data Security Plan',
|
||||
description='Data Security Plan',
|
||||
is_master_spec=False,
|
||||
|
|
Loading…
Reference in New Issue