down to just 38 failed tests

This commit is contained in:
Dan 2022-02-09 11:37:54 -05:00
parent 148796d311
commit 8e7c8c87c3
4 changed files with 23 additions and 16 deletions

View File

@ -99,7 +99,11 @@ def update_study(study_id, body):
def get_study(study_id, update_status=False):
spec_service = WorkflowSpecService()
categories = spec_service.get_categories()
study = StudyService.get_study(study_id, categories=categories, do_status=update_status)
master_workflow_results = []
if update_status:
study_model = session.query(StudyModel).filter(StudyModel.id == study_id).first()
master_workflow_results = __run_master_spec(study_model, spec_service.master_spec)
study = StudyService().get_study(study_id, categories, master_workflow_results)
if (study is None):
raise ApiError("unknown_study", 'The study "' + study_id + '" is not recognized.', status_code=404)
return StudySchema().dump(study)

View File

@ -1,7 +1,7 @@
import enum
import marshmallow
from marshmallow import EXCLUDE, post_load, fields
from marshmallow import EXCLUDE, post_load, fields, INCLUDE
from sqlalchemy import func
from crc import db, ma
@ -30,7 +30,7 @@ class WorkflowSpecCategorySchema(ma.Schema):
class WorkflowSpecInfo(object):
def __init__(self, id, display_name, description, is_master_spec=False,
standalone=False, library=False, primary_file_name='', primary_process_id='',
libraries=[], category_id=None, display_order=0, is_review=False):
libraries=[], category_id="", display_order=0, is_review=False):
self.id = id # Sting unique id
self.display_name = display_name
self.description = description
@ -50,8 +50,8 @@ class WorkflowSpecInfoSchema(ma.Schema):
fields = ["id", "display_name", "description", "is_master_spec",
"standalone", "library", "primary_file_name", "primary_process_id", "is_review",
"libraries", "display_order", "is_master_spec", "is_review", "category_id"]
unknown = EXCLUDE
category_id = marshmallow.fields.String(required=False, allow_none=True, missing="", default="")
unknown = INCLUDE
category_id = marshmallow.fields.String()
@post_load
def make_spec(self, data, **kwargs):

View File

@ -35,7 +35,7 @@ class FileSystemService(object):
@staticmethod
def category_path_for_spec(spec):
if spec.is_master_spec:
return os.path.join(FileSystemService.root_path(), FileSystemService.MASTER_SPECIFICATION)
return os.path.join(FileSystemService.root_path())
elif spec.library:
category_path = FileSystemService.category_path(FileSystemService.LIBRARY_SPECS)
elif spec.standalone:
@ -45,8 +45,11 @@ class FileSystemService(object):
return category_path
@staticmethod
def workflow_path(spec: WorkflowSpecInfo):
category_path = FileSystemService.category_path_for_spec(spec)
return os.path.join(category_path, spec.display_name)
if spec.is_master_spec:
return os.path.join(FileSystemService.root_path(), FileSystemService.MASTER_SPECIFICATION)
else:
category_path = FileSystemService.category_path_for_spec(spec)
return os.path.join(category_path, spec.display_name)
def next_display_order(self, spec):
path = self.category_path_for_spec(spec)

View File

@ -14,7 +14,7 @@ from crc.services.workflow_processor import WorkflowProcessor
class TestLookupService(BaseTest):
def test_lookup_returns_good_error_on_bad_field(self):
spec = BaseTest.load_test_spec('enum_options_with_search')
spec = self.load_test_spec('enum_options_with_search')
workflow = self.create_workflow('enum_options_with_search')
file_model = session.query(FileModel).filter(FileModel.name == "customer_list.xlsx").first()
file_data_model = session.query(FileDataModel).filter(FileDataModel.file_model == file_model).first()
@ -22,7 +22,7 @@ class TestLookupService(BaseTest):
LookupService.lookup(workflow, "Task_Enum_Lookup", "not_the_right_field", "sam", limit=10)
def test_lookup_table_is_not_created_more_than_once(self):
spec = BaseTest.load_test_spec('enum_options_with_search')
spec = self.load_test_spec('enum_options_with_search')
workflow = self.create_workflow('enum_options_with_search')
LookupService.lookup(workflow, "Task_Enum_Lookup", "sponsor", "sam", limit=10)
LookupService.lookup(workflow, "Task_Enum_Lookup", "sponsor", "something", limit=10)
@ -35,7 +35,7 @@ class TestLookupService(BaseTest):
self.assertEqual(28, len(lookup_data))
def test_updates_to_file_cause_lookup_rebuild(self):
spec = BaseTest.load_test_spec('enum_options_with_search')
spec = self.load_test_spec('enum_options_with_search')
workflow = self.create_workflow('enum_options_with_search')
LookupService.lookup(workflow, "Task_Enum_Lookup", "sponsor", "sam", limit=10)
lookup_records = session.query(LookupFileModel).all()
@ -65,7 +65,7 @@ class TestLookupService(BaseTest):
self.assertEqual(4, len(lookup_data))
def test_lookup_based_on_id(self):
spec = BaseTest.load_test_spec('enum_options_from_file')
spec = self.load_test_spec('enum_options_from_file')
workflow = self.create_workflow('enum_options_from_file')
processor = WorkflowProcessor(workflow)
processor.do_engine_steps()
@ -76,7 +76,7 @@ class TestLookupService(BaseTest):
def test_lookup_with_two_spreadsheets_with_the_same_field_name_in_different_forms(self):
spec = BaseTest.load_test_spec('enum_options_competing_files')
spec = self.load_test_spec('enum_options_competing_files')
workflow = self.create_workflow('enum_options_competing_files')
processor = WorkflowProcessor(workflow)
@ -107,7 +107,7 @@ class TestLookupService(BaseTest):
def test_some_full_text_queries(self):
spec = BaseTest.load_test_spec('enum_options_from_file')
spec = self.load_test_spec('enum_options_from_file')
workflow = self.create_workflow('enum_options_from_file')
processor = WorkflowProcessor(workflow)
processor.do_engine_steps()
@ -168,7 +168,7 @@ class TestLookupService(BaseTest):
self.assertEqual("Other", results[0]['CUSTOMER_NAME'], "Can't find the word 'other', which is an english stop word")
def test_find_by_id(self):
spec = BaseTest.load_test_spec('enum_options_from_file')
spec = self.load_test_spec('enum_options_from_file')
workflow = self.create_workflow('enum_options_from_file')
processor = WorkflowProcessor(workflow)
processor.do_engine_steps()
@ -179,7 +179,7 @@ class TestLookupService(BaseTest):
self.assertEquals('UVA - INTERNAL - GM USE ONLY', first_result['CUSTOMER_NAME'])
def test_lookup_fails_for_xls(self):
spec = BaseTest.load_test_spec('enum_options_with_search')
spec = self.load_test_spec('enum_options_with_search')
# Using an old xls file should raise an error
file_data_xls = SpecFileService().get_data(spec, 'sponsors.xls')