diff --git a/tests/test_workflow_api.py b/tests/test_workflow_api.py index 6f0e6975..c33e5b2e 100644 --- a/tests/test_workflow_api.py +++ b/tests/test_workflow_api.py @@ -1,3 +1,4 @@ +from crc.models.workflow import WorkflowLibraryModel from tests.base_test import BaseTest from crc import session @@ -60,5 +61,34 @@ class TestWorkflowApi(BaseTest): self.assertIsNotNone(returned.get('libraries')) self.assertEqual(len(returned['libraries']),0) + def test_library_cleanup(self): + self.load_example_data() + spec1 = ExampleDataLoader().create_spec('hello_world', 'Hello World', category_id=0, library=False, + from_tests=True) + + spec2 = ExampleDataLoader().create_spec('hello_world_lib', 'Hello World Library', category_id=0, library=True, + from_tests=True) + user = session.query(UserModel).first() + self.assertIsNotNone(user) + + rv = self.app.post(f'/v1.0/workflow-specification/%s/library/%s'%(spec1.id,spec2.id), + follow_redirects=True, + content_type="application/json", + headers=self.logged_in_headers()) + self.assert_success(rv) + + rv = self.app.get(f'/v1.0/workflow-specification/%s'%spec1.id,follow_redirects=True, + content_type="application/json", + headers=self.logged_in_headers()) + returned=rv.json + lib = session.query(WorkflowLibraryModel).filter(WorkflowLibraryModel.library_spec_id==spec2.id).first() + self.assertIsNotNone(lib) + + rv = self.app.delete(f'/v1.0/workflow-specification/%s'%(spec1.id),follow_redirects=True, + content_type="application/json", + headers=self.logged_in_headers()) + + lib = session.query(WorkflowLibraryModel).filter(WorkflowLibraryModel.library_spec_id==spec2.id).first() + self.assertIsNone(lib)