mirror of
https://github.com/sartography/cr-connect-workflow.git
synced 2025-02-24 05:38:25 +00:00
Fixing failing tests
This commit is contained in:
parent
389d2b413e
commit
ba2eef0ec9
@ -16,7 +16,7 @@ class DataStoreBase(object):
|
|||||||
if script_name == 'study_data_set':
|
if script_name == 'study_data_set':
|
||||||
record = {'task_id': task_id, 'study_id': study_id, 'workflow_id': workflow_id, key: value}
|
record = {'task_id': task_id, 'study_id': study_id, 'workflow_id': workflow_id, key: value}
|
||||||
elif script_name == 'file_data_set':
|
elif script_name == 'file_data_set':
|
||||||
record = {'task_id': task_id, 'study_id': study_id, 'workflow_id': workflow_id, 'file_id': file_id, key: value}
|
record = {'task_id': task_id, 'study_id': study_id, 'workflow_id': workflow_id, 'document_id': file_id, key: value}
|
||||||
elif script_name == 'user_data_set':
|
elif script_name == 'user_data_set':
|
||||||
record = {'task_id': task_id, 'study_id': study_id, 'workflow_id': workflow_id, 'user_id': user_id, key: value}
|
record = {'task_id': task_id, 'study_id': study_id, 'workflow_id': workflow_id, 'user_id': user_id, key: value}
|
||||||
g.validation_data_store.append(record)
|
g.validation_data_store.append(record)
|
||||||
@ -37,7 +37,7 @@ class DataStoreBase(object):
|
|||||||
return self.get_data_common(study_id, user_id, 'study_data_get', file_id, *args)
|
return self.get_data_common(study_id, user_id, 'study_data_get', file_id, *args)
|
||||||
elif script_name == 'file_data_get':
|
elif script_name == 'file_data_get':
|
||||||
for record in g.validation_data_store:
|
for record in g.validation_data_store:
|
||||||
if 'file_id' in record and record['file_id'] == file_id and key in record:
|
if 'document_id' in record and record['document_id'] == file_id and key in record:
|
||||||
return record[key]
|
return record[key]
|
||||||
return self.get_data_common(study_id, user_id, 'file_data_get', file_id, *args)
|
return self.get_data_common(study_id, user_id, 'file_data_get', file_id, *args)
|
||||||
elif script_name == 'user_data_get':
|
elif script_name == 'user_data_get':
|
||||||
@ -84,7 +84,7 @@ class DataStoreBase(object):
|
|||||||
if study_id:
|
if study_id:
|
||||||
query = query.filter(DataStoreModel.study_id == study_id)
|
query = query.filter(DataStoreModel.study_id == study_id)
|
||||||
elif file_id:
|
elif file_id:
|
||||||
query = query.filter(DataStoreModel.file_id == file_id)
|
query = query.filter(DataStoreModel.document_id == file_id)
|
||||||
elif user_id:
|
elif user_id:
|
||||||
query = query.filter(DataStoreModel.user_id == user_id)
|
query = query.filter(DataStoreModel.user_id == user_id)
|
||||||
result = query.order_by(desc(DataStoreModel.last_updated)).all()
|
result = query.order_by(desc(DataStoreModel.last_updated)).all()
|
||||||
@ -107,7 +107,7 @@ class DataStoreBase(object):
|
|||||||
study_id=study_id,
|
study_id=study_id,
|
||||||
task_spec=task_spec,
|
task_spec=task_spec,
|
||||||
user_id=user_id, # Make this available to any User
|
user_id=user_id, # Make this available to any User
|
||||||
file_id=file_id,
|
document_id=file_id,
|
||||||
workflow_id=workflow_id,
|
workflow_id=workflow_id,
|
||||||
spec_id=workflow_spec_id)
|
spec_id=workflow_spec_id)
|
||||||
session.add(dsm)
|
session.add(dsm)
|
||||||
@ -119,7 +119,7 @@ class DataStoreBase(object):
|
|||||||
self.check_args(args, 2, script_name)
|
self.check_args(args, 2, script_name)
|
||||||
record = session.query(DataStoreModel).filter_by(study_id=study_id,
|
record = session.query(DataStoreModel).filter_by(study_id=study_id,
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
file_id=file_id,
|
document_id=file_id,
|
||||||
key=args[0]).first()
|
key=args[0]).first()
|
||||||
if record:
|
if record:
|
||||||
return record.value
|
return record.value
|
||||||
@ -132,7 +132,7 @@ class DataStoreBase(object):
|
|||||||
def get_multi_common(study_id, user_id, file_id=None):
|
def get_multi_common(study_id, user_id, file_id=None):
|
||||||
results = session.query(DataStoreModel).filter_by(study_id=study_id,
|
results = session.query(DataStoreModel).filter_by(study_id=study_id,
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
file_id=file_id)
|
document_id=file_id)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -142,7 +142,7 @@ class DataStoreBase(object):
|
|||||||
if user_id:
|
if user_id:
|
||||||
query = query.filter(DataStoreModel.user_id == user_id)
|
query = query.filter(DataStoreModel.user_id == user_id)
|
||||||
elif file_id:
|
elif file_id:
|
||||||
query = query.filter(DataStoreModel.file_id == file_id)
|
query = query.filter(DataStoreModel.document_id == file_id)
|
||||||
elif study_id:
|
elif study_id:
|
||||||
query = query.filter(DataStoreModel.study_id == study_id)
|
query = query.filter(DataStoreModel.study_id == study_id)
|
||||||
record = query.first()
|
record = query.first()
|
||||||
|
@ -19,16 +19,16 @@ class TestDataStoreValidation(BaseTest):
|
|||||||
def add_test_file():
|
def add_test_file():
|
||||||
binary_data = b'1234'
|
binary_data = b'1234'
|
||||||
md5_hash = UUID(hashlib.md5(binary_data).hexdigest())
|
md5_hash = UUID(hashlib.md5(binary_data).hexdigest())
|
||||||
file_model = DocumentModel(
|
model = DocumentModel(
|
||||||
name='my_test_file',
|
name='my_test_file',
|
||||||
type=FileType.pdf.value,
|
type=FileType.pdf.value,
|
||||||
content_type='application/pdf',
|
content_type='application/pdf',
|
||||||
irb_doc_code = 'Study_Protocol_Document',
|
irb_doc_code='Study_Protocol_Document',
|
||||||
data=binary_data,
|
data=binary_data,
|
||||||
md5_hash=md5_hash,
|
md5_hash=md5_hash,
|
||||||
archived=False
|
archived=False
|
||||||
)
|
)
|
||||||
session.add(file_model)
|
session.add(model)
|
||||||
session.commit()
|
session.commit()
|
||||||
file_id = session.query(DocumentModel.id).filter(DocumentModel.name == 'my_test_file').scalar()
|
file_id = session.query(DocumentModel.id).filter(DocumentModel.name == 'my_test_file').scalar()
|
||||||
return file_id
|
return file_id
|
||||||
@ -42,7 +42,7 @@ class TestDataStoreValidation(BaseTest):
|
|||||||
task_spec=None,
|
task_spec=None,
|
||||||
spec_id=spec_model.id,
|
spec_id=spec_model.id,
|
||||||
user_id=None,
|
user_id=None,
|
||||||
file_id=None,
|
document_id=None,
|
||||||
value='previous_study_data_value'
|
value='previous_study_data_value'
|
||||||
|
|
||||||
)
|
)
|
||||||
@ -54,7 +54,7 @@ class TestDataStoreValidation(BaseTest):
|
|||||||
task_spec=None,
|
task_spec=None,
|
||||||
spec_id=spec_model.id,
|
spec_id=spec_model.id,
|
||||||
user_id=user.uid,
|
user_id=user.uid,
|
||||||
file_id=None,
|
document_id=None,
|
||||||
value='previous_user_data_value'
|
value='previous_user_data_value'
|
||||||
)
|
)
|
||||||
session.add(dsm)
|
session.add(dsm)
|
||||||
@ -65,7 +65,7 @@ class TestDataStoreValidation(BaseTest):
|
|||||||
task_spec=None,
|
task_spec=None,
|
||||||
spec_id=spec_model.id,
|
spec_id=spec_model.id,
|
||||||
user_id=None,
|
user_id=None,
|
||||||
file_id=file_id,
|
document_id=file_id,
|
||||||
value='previous_file_data_value'
|
value='previous_file_data_value'
|
||||||
)
|
)
|
||||||
session.add(dsm)
|
session.add(dsm)
|
||||||
@ -81,7 +81,7 @@ class TestDataStoreValidation(BaseTest):
|
|||||||
task_spec=None,
|
task_spec=None,
|
||||||
spec_id=None,
|
spec_id=None,
|
||||||
user_id=None,
|
user_id=None,
|
||||||
file_id=file_id,
|
document_id=file_id,
|
||||||
value='previous_file_data_value_1'
|
value='previous_file_data_value_1'
|
||||||
)
|
)
|
||||||
session.add(dsm)
|
session.add(dsm)
|
||||||
@ -95,7 +95,7 @@ class TestDataStoreValidation(BaseTest):
|
|||||||
task_spec=None,
|
task_spec=None,
|
||||||
spec_id=None,
|
spec_id=None,
|
||||||
user_id=None,
|
user_id=None,
|
||||||
file_id=file_id,
|
document_id=file_id,
|
||||||
value='previous_file_data_value_2'
|
value='previous_file_data_value_2'
|
||||||
)
|
)
|
||||||
session.add(dsm)
|
session.add(dsm)
|
||||||
@ -109,7 +109,7 @@ class TestDataStoreValidation(BaseTest):
|
|||||||
task_spec=None,
|
task_spec=None,
|
||||||
spec_id=None,
|
spec_id=None,
|
||||||
user_id=None,
|
user_id=None,
|
||||||
file_id=file_id,
|
document_id=file_id,
|
||||||
value='previous_file_data_value_3'
|
value='previous_file_data_value_3'
|
||||||
)
|
)
|
||||||
session.add(dsm)
|
session.add(dsm)
|
||||||
@ -208,7 +208,7 @@ class TestDataStoreValidation(BaseTest):
|
|||||||
file_id = self.add_test_file()
|
file_id = self.add_test_file()
|
||||||
self.add_multiple_records(file_id)
|
self.add_multiple_records(file_id)
|
||||||
|
|
||||||
result = session.query(DataStoreModel).filter(DataStoreModel.file_id == file_id).all()
|
result = session.query(DataStoreModel).filter(DataStoreModel.document_id == file_id).all()
|
||||||
self.assertEqual(3, len(result))
|
self.assertEqual(3, len(result))
|
||||||
previous_values = ['previous_file_data_value_1', 'previous_file_data_value_2', 'previous_file_data_value_3']
|
previous_values = ['previous_file_data_value_1', 'previous_file_data_value_2', 'previous_file_data_value_3']
|
||||||
for record in result:
|
for record in result:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user