Commit aad9b97a authored by Mikaël Salson's avatar Mikaël Salson
Browse files

Merge branch 'feature-s/fix_unit_tests' into 'dev'

Fix server unit tests

See merge request !165
parents fc5c38e8 70bed854
Pipeline #19761 passed with stages
in 48 seconds
......@@ -176,8 +176,9 @@ test_server_unit:
- pip install -r requirements.txt
- make -C server install_web2py_standalone
- make -C server launch_fuse_server
- make unit_server
- make unit_server || (make -C server kill_fuse_server; deactivate; false)
- make -C server kill_fuse_server
- deactivate
only:
- /^feature-[sw]\/.*$/
- /^hotfix-[sw]\/.*$/
......@@ -235,4 +236,4 @@ stop_deploy_review:
- /^feature-[cw]\/.*$/
- /^hotfix-[cw]\/.*$/
tags:
- web
\ No newline at end of file
- web
......@@ -9,7 +9,7 @@ install_web2py:
cp -i web2py/applications/vidjil/modules/defs.py.sample web2py/applications/vidjil/modules/defs.py
unit: clean_unit_tests
cd web2py; python web2py.py -S vidjil -M -R testRunner.py
python web2py/web2py.py -S vidjil -M -R testRunner.py
install_web2py_standalone: install_web2py
mkdir -p web2py/applications/vidjil/databases web2py/upload/uploads web2py/result/results
......
......@@ -177,7 +177,7 @@ def all():
list.load_creator_names()
list.load_sample_information()
list.load_config_information()
if isAdmin or len(get_group_list()) > 1:
if isAdmin or len(get_group_list(auth)) > 1:
list.load_permitted_groups()
list.load_anon_permissions()
result = list.get_values()
......
......@@ -70,7 +70,7 @@ class SampleSet(object):
fields.append({'name': 'name', 'sort': 'name', 'call': self.get_name, 'width': 200, 'public': True})
fields.append({'name': 'info', 'sort': 'info', 'call': self.get_tagged_info, 'width': None, 'public': True})
fields.append({'name': 'results', 'sort': 'confs', 'call': self.get_config_urls, 'width': None, 'public': True})
if auth.is_admin() or len(get_group_list()) > 1:
if auth.is_admin() or len(get_group_list(auth)) > 1:
fields.append({'name': 'groups', 'sort': 'groups', 'call': self.get_groups_string, 'width': 100, 'public': True})
fields.append({'name': 'creator', 'sort': 'creator', 'call': self.get_creator, 'width': 100, 'public': True})
fields.append({'name': 'files', 'sort': 'file_count', 'call': self.get_files, 'width': 100, 'public': True})
......
from gluon import current
def get_group_list():
auth = current.auth
def get_group_list(auth):
if (auth.is_admin()):
return db(db.auth_group).select(db.auth_group.id, db.auth_group.role)
else:
......@@ -15,7 +12,7 @@ def get_default_creation_group(auth):
max_group = auth.user_group()
group_dict = {}
max_elements = 0
group_list = get_group_list()
group_list = get_group_list(auth)
for group in group_list:
if (auth.is_admin()
or auth.has_permission(PermissionEnum.create.value, 'sample_set', 0, group_id = group.id)):
......
......@@ -30,8 +30,6 @@ class MigrateLogger():
def getLogger(self):
return self.log
log = MigrateLogger()
def get_dict_from_row(row):
'''
Create a dict element from a Row element
......@@ -216,10 +214,10 @@ class Importer():
self.log.debug("new %s: %d" % (table, oid))
if map_val:
if table not in self.mappings:
self.mappings[table] = IdMapper(log)
self.mappings[table] = IdMapper(self.log)
self.mappings[table].setMatchingId(long(vid), oid)
def copy_files(data, src, dest):
def copy_files(data, src, dest, log=MigrateLogger()):
file_fields = {'results_file': 'data_file',
'analysis_file': 'analysis_file',
'fused_file': 'fused_file'}
......@@ -233,7 +231,7 @@ def copy_files(data, src, dest):
log.debug("Copying %s" % data[t][entry][file_fields[t]])
copy(src + '/' + data[t][entry][file_fields[t]], dest + '/' + data[t][entry][file_fields[t]])
def export_peripheral_data(extractor, data_dict, sample_set_ids):
def export_peripheral_data(extractor, data_dict, sample_set_ids, log=MigrateLogger()):
sequence_rows = extractor.getSequenceFiles(sample_set_ids)
data_dict['sequence_file'], data_dict['membership'] = extractor.populateSequenceFiles(sequence_rows)
......@@ -255,7 +253,7 @@ def export_peripheral_data(extractor, data_dict, sample_set_ids):
return data_dict
def export_group_data(filesrc, filepath, groupid):
def export_group_data(filesrc, filepath, groupid, log=MigrateLogger()):
log.info("exporting group data")
ext = GroupExtractor(db, log)
......@@ -272,7 +270,7 @@ def export_group_data(filesrc, filepath, groupid):
sample_set_ids = patient_ssids + run_ssids + generic_ssids
tables = export_peripheral_data(ext, tables, sample_set_ids)
tables = export_peripheral_data(ext, tables, sample_set_ids, log=log)
if not os.path.exists(filepath):
os.makedirs(filepath)
......@@ -281,10 +279,10 @@ def export_group_data(filesrc, filepath, groupid):
json.dump(tables, outfile, ensure_ascii=False, encoding='utf-8')
log.info("copying files from %s to %s" % (filesrc, filepath))
copy_files(tables, filesrc, filepath + '/files')
copy_files(tables, filesrc, filepath + '/files', log=log)
log.info("done")
def export_sample_set_data(filesrc, filepath, sample_type, sample_ids):
def export_sample_set_data(filesrc, filepath, sample_type, sample_ids, log=MigrateLogger()):
log.info("exporting sample set data")
ext = SampleSetExtractor(db, log)
......@@ -293,7 +291,7 @@ def export_sample_set_data(filesrc, filepath, sample_type, sample_ids):
rows = ext.getAccessible(sample_type, sample_ids)
tables[sample_type], sample_set_ids = ext.populateSets(rows)
tables = export_peripheral_data(ext, tables, sample_set_ids)
tables = export_peripheral_data(ext, tables, sample_set_ids, log=log)
if not os.path.exists(filepath):
os.makedirs(filepath)
......@@ -306,7 +304,7 @@ def export_sample_set_data(filesrc, filepath, sample_type, sample_ids):
log.info("done")
def import_data(filesrc, filedest, groupid, config=None, dry_run=False):
def import_data(filesrc, filedest, groupid, config=None, dry_run=False, log=MigrateLogger()):
log.info("importing data")
data = {}
with open(filesrc + '/export.json', 'r') as infile:
......@@ -338,7 +336,7 @@ def import_data(filesrc, filedest, groupid, config=None, dry_run=False):
else:
db.commit()
log.info("copying files from %s to %s" % (filesrc, filedest))
copy_files(data, filesrc + '/files', filedest)
copy_files(data, filesrc + '/files', filedest, log=log)
log.info("done")
except:
log.error("something went wrong, rolling back")
......@@ -371,18 +369,19 @@ def main():
args = parser.parse_args()
log = MigrateLogger()
if args.debug:
log.log.setLevel(logging.DEBUG)
if args.command == 'export':
if args.mode == 'group':
export_group_data(args.filesrc, args.filepath, args.groupid)
export_group_data(args.filesrc, args.filepath, args.groupid, log)
elif args.mode == 'sample_set':
export_sample_set_data(args.filesrc, args.filepath, args.sample_type, args.ssids)
export_sample_set_data(args.filesrc, args.filepath, args.sample_type, args.ssids, log)
elif args.command == 'import':
if args.dry:
log.log.setLevel(logging.DEBUG)
import_data(args.filesrc, args.filepath, args.groupid, args.config, args.dry)
import_data(args.filesrc, args.filepath, args.groupid, args.config, args.dry, log)
if __name__ == '__main__':
main()
......@@ -74,7 +74,7 @@ class DefaultController(unittest.TestCase):
request.vars['sample_set_id'] = fake_sample_set_id
resp = get_data()
self.assertNotEqual(resp.find('segmented":[742377]'), -1, "get_data doesn't return a valid json " + resp)
self.assertNotEqual(resp.find('segmented":[742377'), -1, "get_data doesn't return a valid json " + resp)
self.assertNotEqual(resp.find('(config_test_popipo)'), -1, "get_data doesn't return a valid json")
......@@ -101,7 +101,7 @@ class DefaultController(unittest.TestCase):
if resp.has_key('success') and resp['success'] == 'false':
self.assertTrue(defs.PORT_FUSE_SERVER is None, 'get_custom_data returns error without fuse server')
else:
self.assertEqual(resp['reads']['segmented'][0], resp['reads']['segmented'][1], "get_custom_data doesn't return a valid json")
self.assertEqual(resp['reads']['segmented'][0], resp['reads']['segmented'][2], "get_custom_data doesn't return a valid json")
def testSaveAnalysis(self):
class emptyClass( object ):
......
......@@ -37,12 +37,12 @@ class TagController(unittest.TestCase):
resp = auto_complete()
self.assertNotEqual(resp.find("missing group ids"), -1, "auto_complete did not fail correctly")
request.vars["group_ids"] = "[]"
request.vars["keys"] = "[]"
resp = auto_complete()
self.assertEqual(resp.find("missing group ids"), -1, "auto_complete failed to detect group_ids param")
self.assertEqual(resp, "{}", "auto_complete returned an unexpected response")
request.vars["group_ids"] = "[%d,%d]" % (unique_group, fake_group_id)
request.vars["keys"] = "[%d,%d]" % (unique_group, fake_group_id)
resp = auto_complete()
json_resp = json.loads(resp)
self.assertTrue(json_resp.has_key(str(unique_group)), "missing tag for unique_group: %s" % unique_group)
......
......@@ -167,19 +167,12 @@ class VidjilauthModel(unittest.TestCase):
group_qui = db.auth_group.insert(role="group5", description="fifth group")
admin_group = db.auth_group.insert(role="admin", description="admin group")
admin_group = 1
db.auth_membership.insert(user_id=admin_user_id, group_id=admin_group)
db.group_assoc.insert(first_group_id = parent_group, second_group_id = group_sec)
db.group_assoc.insert(first_group_id = group_qui, second_group_id = group)
db.auth_permission.insert(name=PermissionEnum.access.value, table_name='sample_set', group_id=admin_group, record_id=0)
db.auth_permission.insert(name=PermissionEnum.access.value, table_name='patient', group_id=admin_group, record_id=0)
db.auth_permission.insert(name=PermissionEnum.access.value, table_name='run', group_id=admin_group, record_id=0)
db.auth_permission.insert(name=PermissionEnum.read.value, table_name='sample_set', group_id=admin_group, record_id=0)
db.auth_permission.insert(name=PermissionEnum.read.value, table_name='patient', group_id=admin_group, record_id=0)
db.auth_permission.insert(name=PermissionEnum.read.value, table_name='run', group_id=admin_group, record_id=0)
db.auth_permission.insert(name=PermissionEnum.upload.value, table_name='sample_set', group_id=group_qua, record_id=0)
db.auth_permission.insert(name=PermissionEnum.run.value, table_name='sample_set', group_id=group_qua, record_id=0)
db.auth_permission.insert(name=PermissionEnum.access.value, table_name='sample_set', group_id=group_qua, record_id=sample_set_id_ter)
......@@ -270,8 +263,8 @@ class VidjilauthModel(unittest.TestCase):
result = auth.is_admin(user=auth.user_id)
self.assertFalse(result, "User %d should not have admin permissions" % auth.user_id)
result = auth.is_admin(user=user_id)
self.assertTrue(result, "User %d should have admin permissions" % user_id)
result = auth.is_admin(user=admin_user_id)
self.assertTrue(result, "User %d should have admin permissions" % admin_user_id)
def testIsInGroup(self):
parent_group_name = db(db.auth_group.id == parent_group).select()[0].role
......@@ -297,9 +290,9 @@ class VidjilauthModel(unittest.TestCase):
result = auth.can_modify_patient(patient_id_qua, user_id_sec)
self.assertTrue(result, "User %d should be able to modify patient %d" % (user_id_sec, patient_id_qua))
result = auth.can_modify_patient(patient_id_qua, user_id)
result = auth.can_modify_patient(patient_id_qua, admin_user_id)
self.assertTrue(result,
"User %d is a member of admin group and is missing permissions to modify patient %d" % (user_id, patient_id_qua))
"User %d is a member of admin group and is missing permissions to modify patient %d" % (admin_user_id, patient_id_qua))
def testCanModifyRun(self):
result = auth.can_modify_run(run_id)
......@@ -308,9 +301,9 @@ class VidjilauthModel(unittest.TestCase):
result = auth.can_modify_run(run_id, user_id_sec)
self.assertTrue(result, "User %d should be able to modify run %d" % (user_id_sec, run_id))
result = auth.can_modify_run(run_id, user_id)
result = auth.can_modify_run(run_id, admin_user_id)
self.assertTrue(result,
"User %d is a member of admin group and is missing permissions to modify run %d" % (user_id, run_id))
"User %d is a member of admin group and is missing permissions to modify run %d" % (admin_user_id, run_id))
def testCanModifySampleSet(self):
result = auth.can_modify_sample_set(first_sample_set_id)
......@@ -319,9 +312,9 @@ class VidjilauthModel(unittest.TestCase):
result = auth.can_modify_sample_set(first_sample_set_id, user_id_sec)
self.assertTrue(result, "User %d should be able to modify sample_set %d" % (user_id_sec, first_sample_set_id))
result = auth.can_modify_sample_set(first_sample_set_id, user_id)
result = auth.can_modify_sample_set(first_sample_set_id, admin_user_id)
self.assertTrue(result,
"User %d is a member of admin group and is missing permissions to modify sample_set %d" % (user_id, first_sample_set_id))
"User %d is a member of admin group and is missing permissions to modify sample_set %d" % (admin_user_id, first_sample_set_id))
def testCanModifyGeneric(self):
# patient data
......@@ -331,9 +324,9 @@ class VidjilauthModel(unittest.TestCase):
result = auth.can_modify('patient', patient_id_qua, user_id_sec)
self.assertTrue(result, "User %d should be able to modify patient %d" % (user_id_sec, patient_id_qua))
result = auth.can_modify('patient', patient_id_qua, user_id)
result = auth.can_modify('patient', patient_id_qua, admin_user_id)
self.assertTrue(result,
"User %d is a member of admin group and is missing permissions to modify patient %d" % (user_id, patient_id_qua))
"User %d is a member of admin group and is missing permissions to modify patient %d" % (admin_user_id, patient_id_qua))
# run data
result = auth.can_modify('run', run_id)
......@@ -342,9 +335,9 @@ class VidjilauthModel(unittest.TestCase):
result = auth.can_modify('run', run_id, user_id_sec)
self.assertTrue(result, "User %d should be able to modify run %d" % (user_id_sec, run_id))
result = auth.can_modify('run', run_id, user_id)
result = auth.can_modify('run', run_id, admin_user_id)
self.assertTrue(result,
"User %d is a member of admin group and is missing permissions to modify run %d" % (user_id, run_id))
"User %d is a member of admin group and is missing permissions to modify run %d" % (admin_user_id, run_id))
# generic data
result = auth.can_modify('generic', generic_id)
......@@ -353,9 +346,9 @@ class VidjilauthModel(unittest.TestCase):
result = auth.can_modify('generic', generic_id, user_id_sec)
self.assertTrue(result, "User %d should be able to modify generic %d" % (user_id_sec, generic_id))
result = auth.can_modify('generic', generic_id, user_id)
result = auth.can_modify('generic', generic_id, admin_user_id)
self.assertTrue(result,
"User %d is a member of admin group and is missing permissions to modify generic %d" % (user_id, generic_id))
"User %d is a member of admin group and is missing permissions to modify generic %d" % (admin_user_id, generic_id))
def testCanModifyFile(self):
result = auth.can_modify_file(file_id)
......@@ -364,9 +357,9 @@ class VidjilauthModel(unittest.TestCase):
result = auth.can_modify_file(file_id, user_id_sec)
self.assertTrue(result, "User %d should be able to modify file %d" % (user_id_sec, file_id))
result = auth.can_modify_file(file_id, user_id)
result = auth.can_modify_file(file_id, admin_user_id)
self.assertTrue(result,
"User %d is a member of admin group and is missing permissions to modify file %d" % (user_id, file_id))
"User %d is a member of admin group and is missing permissions to modify file %d" % (admin_user_id, file_id))
def testCanModifyConfig(self):
result = auth.can_modify_config(config_id)
......@@ -375,9 +368,9 @@ class VidjilauthModel(unittest.TestCase):
result = auth.can_modify_config(config_id, user_id_sec)
self.assertTrue(result, "User %d should be able to modify config %d" % (user_id_sec, config_id))
result = auth.can_modify_config(config_id, user_id)
result = auth.can_modify_config(config_id, admin_user_id)
self.assertTrue(result,
"User %d is a member of admin group and is missing permissions to modify config %d" % (user_id, config_id))
"User %d is a member of admin group and is missing permissions to modify config %d" % (admin_user_id, config_id))
def testCanModifyGroup(self):
result = auth.can_modify_group(parent_group)
......@@ -386,13 +379,13 @@ class VidjilauthModel(unittest.TestCase):
result = auth.can_modify_group(parent_group, user_id_sec)
self.assertTrue(result, "User %d should be able to modify group %d" % (user_id_sec, parent_group))
result = auth.can_modify_group(parent_group, user_id)
result = auth.can_modify_group(parent_group, admin_user_id)
self.assertTrue(result,
"User %d is a member of admin group and is missing permissions to modify group %d" % (user_id, parent_group))
"User %d is a member of admin group and is missing permissions to modify group %d" % (admin_user_id, parent_group))
def testCanModifyPreProcess(self):
result = auth.can_modify_pre_process(pre_process_id, user_id)
self.assertTrue(result, "User %d should be able to modify pre process %d" % (user_id, pre_process_id))
result = auth.can_modify_pre_process(pre_process_id, admin_user_id)
self.assertTrue(result, "User %d should be able to modify pre process %d" % (admin_user_id, pre_process_id))
result = auth.can_modify_pre_process(pre_process_id, user_id_sec)
self.assertFalse(result, "User %d should be able to modify pre process %d" % (user_id_sec, pre_process_id))
......@@ -406,9 +399,9 @@ class VidjilauthModel(unittest.TestCase):
self.assertTrue(result,
"User %d should be able to process files for patient %d" % (user_id_sec, patient_id))
result = auth.can_process_file('patient', patient_id, user_id)
result = auth.can_process_file('patient', patient_id, admin_user_id)
self.assertTrue(result,
"User %d is a member of admin group and is missing permissions to process files" % user_id)
"User %d is a member of admin group and is missing permissions to process files" % admin_user_id)
def testCanProcessSampleSet(self):
result = auth.can_process_sample_set(sample_set_id_sec)
......@@ -427,9 +420,9 @@ class VidjilauthModel(unittest.TestCase):
self.assertFalse(result,
"User %d should not be able to process files for sample_set %d" % (user_id_sec, sample_set_id_ter))
result = auth.can_process_sample_set(sample_set_id, user_id)
result = auth.can_process_sample_set(sample_set_id, admin_user_id)
self.assertTrue(result,
"User %d is a member of admin group and is missing permissions to process files" % user_id)
"User %d is a member of admin group and is missing permissions to process files" % admin_user_id)
def testCanUploadFile(self):
result = auth.can_upload_file('patient', patient_id_sec)
......@@ -440,9 +433,9 @@ class VidjilauthModel(unittest.TestCase):
self.assertTrue(result,
"User %d should be able to upload files for patient %d" % (user_id_sec, patient_id))
result = auth.can_upload_file('patient', patient_id, user_id)
result = auth.can_upload_file('patient', patient_id, admin_user_id)
self.assertTrue(result,
"User %d is a member of admin group and is missing permissions to upload files" % user_id)
"User %d is a member of admin group and is missing permissions to upload files" % admin_user_id)
def testCanUploadSampleSet(self):
result = auth.can_upload_sample_set(sample_set_id_sec)
......@@ -453,9 +446,9 @@ class VidjilauthModel(unittest.TestCase):
self.assertTrue(result,
"User %d should be able to upload files for sample_set %d" % (user_id_sec, sample_set_id))
result = auth.can_upload_sample_set(sample_set_id, user_id)
result = auth.can_upload_sample_set(sample_set_id, admin_user_id)
self.assertTrue(result,
"User %d is a member of admin group and is missing permissions to upload files" % user_id)
"User %d is a member of admin group and is missing permissions to upload files" % admin_user_id)
def testCanUseConfig(self):
result = auth.can_use_config(config_id)
......@@ -464,9 +457,9 @@ class VidjilauthModel(unittest.TestCase):
result = auth.can_use_config(config_id, user_id_sec)
self.assertTrue(result, "User %d should be able to use config %d" % (user_id_sec, config_id))
result = auth.can_use_config(config_id, user_id)
result = auth.can_use_config(config_id, admin_user_id)
self.assertTrue(result,
"User %d is a member of admin group and is missing permissions to use config %d" % (user_id, config_id))
"User %d is a member of admin group and is missing permissions to use config %d" % (admin_user_id, config_id))
def testCanView(self):
result = auth.can_view('patient', patient_id_qua)
......@@ -475,9 +468,9 @@ class VidjilauthModel(unittest.TestCase):
result = auth.can_view('patient', patient_id_qua, user_id_sec)
self.assertTrue(result, "User %d should be able to view patient %d" % (user_id_sec, patient_id_qua))
result = auth.can_view('patient', patient_id_qua, user_id)
result = auth.can_view('patient', patient_id_qua, admin_user_id)
self.assertTrue(result,
"User %d is a member of admin group and is missing permissions to view patient %d" % (user_id, patient_id_qua))
"User %d is a member of admin group and is missing permissions to view patient %d" % (admin_user_id, patient_id_qua))
def testCanViewSampleSet(self):
result = auth.can_view_sample_set(first_sample_set_id)
......@@ -486,9 +479,9 @@ class VidjilauthModel(unittest.TestCase):
result = auth.can_view_sample_set(first_sample_set_id, user_id_sec)
self.assertTrue(result, "User %d should be able to view sample_set %d" % (user_id_sec, first_sample_set_id))
result = auth.can_view_sample_set(first_sample_set_id, user_id)
result = auth.can_view_sample_set(first_sample_set_id, admin_user_id)
self.assertTrue(result,
"User %d is a member of admin group and is missing permissions to view sample_set %d" % (user_id, first_sample_set_id))
"User %d is a member of admin group and is missing permissions to view sample_set %d" % (admin_user_id, first_sample_set_id))
def testCanSavePatient(self):
result = auth.can_save_patient(patient_id_qua)
......@@ -497,9 +490,9 @@ class VidjilauthModel(unittest.TestCase):
result = auth.can_save_patient(patient_id_qua, user_id_sec)
self.assertTrue(result, "User %d should be able to save patient %d" % (user_id_sec, patient_id_qua))
result = auth.can_save_patient(patient_id_qua, user_id)
result = auth.can_save_patient(patient_id_qua, admin_user_id)
self.assertTrue(result,
"User %d is a member of admin group and is missing permissions to save patient %d" % (user_id, patient_id_qua))
"User %d is a member of admin group and is missing permissions to save patient %d" % (admin_user_id, patient_id_qua))
def testCanSaveRun(self):
result = auth.can_save_run(run_id)
......@@ -508,9 +501,9 @@ class VidjilauthModel(unittest.TestCase):
result = auth.can_save_run(run_id, user_id_sec)
self.assertTrue(result, "User %d should be able to save run %d" % (user_id_sec, run_id))
result = auth.can_save_run(run_id, user_id)
result = auth.can_save_run(run_id, admin_user_id)
self.assertTrue(result,
"User %d is a member of admin group and is missing permissions to save run %d" % (user_id, run_id))
"User %d is a member of admin group and is missing permissions to save run %d" % (admin_user_id, run_id))
def testCanSaveSampleSet(self):
result = auth.can_save_sample_set(first_sample_set_id)
......@@ -519,9 +512,9 @@ class VidjilauthModel(unittest.TestCase):
result = auth.can_save_sample_set(first_sample_set_id, user_id_sec)
self.assertTrue(result, "User %d should be able to save sample_set %d" % (user_id_sec, first_sample_set_id))
result = auth.can_save_sample_set(first_sample_set_id, user_id)
result = auth.can_save_sample_set(first_sample_set_id, admin_user_id)
self.assertTrue(result,
"User %d is a member of admin group and is missing permissions to save sample_set %d" % (user_id, first_sample_set_id))
"User %d is a member of admin group and is missing permissions to save sample_set %d" % (admin_user_id, first_sample_set_id))
def testCanViewInfo(self):
result = auth.can_view_info('patient', patient_id_sec, auth.user_id)
......@@ -615,8 +608,8 @@ class VidjilauthModel(unittest.TestCase):
self.assertEqual(Counter(expected), Counter(result), "Expected: %s, but got: %s" % (str(expected), str(result)))
for patient_id in expected:
res = auth.can_modify_patient(patient_id, user_id)
self.assertTrue(res, "User %d is missing permissions on patient %d" % (user_id, patient_id))
res = auth.can_modify_patient(patient_id, admin_user_id)
self.assertTrue(res, "User %d is missing permissions on patient %d" % (admin_user_id, patient_id))
def testAccessibleCanConcordance(self):
res_accessible = [p.id for p in db(auth.vidjil_accessible_query(PermissionEnum.read.value, 'patient', auth.user_id)).select()]
......
......@@ -25,8 +25,9 @@ class TagModel (unittest.TestCase):
self.assertTrue(len(refs) == 1, 'incorrect number of tags match this description')
def test_tags_to_json(self):
tags = get_tags(db, [unique_group, fake_group_id])
json_tags = tags_to_json(tags)
group_ids = [unique_group, fake_group_id]
tags = get_tags(db, group_ids)
json_tags = tags_to_json(tags, group_ids)
tag_dict = json.loads(json_tags)
self.assertTrue(tag_dict.has_key(str(unique_group)), "tag_dict missing key unique_group: %d" % unique_group)
......
......@@ -148,7 +148,7 @@ class MigratorScript(unittest.TestCase):
'run_date': '1970-01-01 00:00:00'}
results = {10: results_file}
imp.importTable('results_file', results, ['sequence_file'], True)
imp.importTable('results_file', results, {'sequence_file': 'sequence_file_id'}, True)
res = db((db.results_file.data_file == 'foobar.txt')
&(db.results_file.run_date == '1970-01-01 00:00:00')
).select()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment