more test passing

This commit is contained in:
Dan 2022-02-09 13:01:26 -05:00
parent db93f9be4e
commit 7e7821a5e7
3 changed files with 12 additions and 13 deletions

View File

@ -42,6 +42,7 @@ def add_file(spec_id):
file = SpecFileService.add_file(workflow_spec, file.filename, file.stream.read())
if not workflow_spec.primary_process_id and file.type == FileType.bpmn:
SpecFileService.set_primary_bpmn(workflow_spec, file.name)
workflow_spec_service.update_spec(workflow_spec)
return FileSchema().dump(file)

View File

@ -360,6 +360,7 @@ class BaseTest(unittest.TestCase):
# workflow_in should be a workflow, not a workflow_api
# we were passing in workflow_api in many of our tests, and
# this caused problems testing standalone workflows
self.workflow_spec_service.scan_file_system()
spec = self.workflow_spec_service.get_spec(workflow_in.workflow_spec_id)
standalone = getattr(spec, 'standalone', False)
prev_completed_task_count = workflow_in.completed_tasks

View File

@ -1,29 +1,26 @@
from tests.base_test import BaseTest
from crc import session
from crc.models.file import FileModel, FileType
import io
import json
from crc.models.workflow import WorkflowSpecInfo, WorkflowSpecInfoSchema
from crc.services.workflow_spec_service import WorkflowSpecService
class TestAutoSetPrimaryBPMN(BaseTest):
def test_auto_set_primary_bpmn(self):
self.load_example_data()
category = self.assure_category_exists()
# Add a workflow spec
spec = WorkflowSpecModel(id='make_cookies', display_name='Cooooookies',
description='Om nom nom delicious cookies', category_id=category.id,
standalone=False)
spec = WorkflowSpecInfo(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',
headers=self.logged_in_headers(),
content_type="application/json",
data=json.dumps(WorkflowSpecModelSchema().dump(spec)))
data=json.dumps(WorkflowSpecInfoSchema().dump(spec)))
self.assert_success(rv)
# grab the spec from the db
db_spec = session.query(WorkflowSpecModel).filter_by(id='make_cookies').first()
db_spec = WorkflowSpecService().get_spec(spec.id)
self.assertEqual(spec.display_name, db_spec.display_name)
self.assertIsNone(db_spec.primary_process_id)
self.assertIsNone(db_spec.primary_file_name)
self.assertEqual('',db_spec.primary_process_id)
self.assertEqual('',db_spec.primary_file_name)
data = {}
data['file'] = io.BytesIO(self.minimal_bpmn("abcdef")), 'my_new_file.bpmn'
@ -33,6 +30,6 @@ class TestAutoSetPrimaryBPMN(BaseTest):
content_type='multipart/form-data', headers=self.logged_in_headers())
self.assert_success(rv)
# Make sure we now have a primary bpmn
db_spec = session.query(WorkflowSpecModel).filter_by(id='make_cookies').first()
db_spec = WorkflowSpecService().get_spec(spec.id)
self.assertEqual(db_spec.primary_process_id, '1')
self.assertEqual(db_spec.primary_file_name, 'my_new_file.bpmn')