def test_box_sync_module_protect_processed(args_and_Lochness): args, Lochness = args_and_Lochness # change protect to true for all actigraphy for study in args.studies: new_list = [] for i in Lochness['box'][study]['file_patterns']['actigraphy']: i['protect'] = True i['processed'] = True new_list.append(i) Lochness['box'][study]['file_patterns']['actigraphy'] = new_list for subject in lochness.read_phoenix_metadata(Lochness): sync(Lochness, subject, dry=False) for study in args.studies: subject_dir = protected_root / study / 'processed' / '1001' assert (subject_dir / 'actigraphy').is_dir() assert len(list((subject_dir / 'actigraphy').glob('*csv'))) > 1 subject_dir = general_root / study / 'processed' / '1001' assert not (subject_dir / 'actigraphy').is_dir() assert len(list((subject_dir / 'actigraphy/processed/').glob('*csv'))) == 0 show_tree_then_delete('tmp_lochness')
def test_box_sync_module_missing_root(args_and_Lochness): args, Lochness = args_and_Lochness # change base for StudyA to missing path Lochness['box']['StudyA']['base'] = 'hahah' for subject in lochness.read_phoenix_metadata(Lochness): sync(Lochness, subject, dry=False) study = 'StudyA' subject_dir = protected_root / study / 'raw' / '1001' assert (subject_dir / 'actigraphy').is_dir() == False show_tree_then_delete('tmp_lochness')
def test_box_sync_module_no_redownload(args_and_Lochness): args, Lochness = args_and_Lochness # change subject name for subject in lochness.read_phoenix_metadata(Lochness): sync(Lochness, subject, dry=False) a_file_path = general_root / 'StudyA' / 'raw' / '1001' / 'actigraphy' / \ 'BLS-F6VVM-GENEActivQC-day22to51.csv' init_time = a_file_path.stat().st_mtime # change subject name for subject in lochness.read_phoenix_metadata(Lochness): sync(Lochness, subject, dry=False) post_time = a_file_path.stat().st_mtime assert init_time == post_time show_tree_then_delete('tmp_lochness')
def test_box_sync_module_missing_subject(args_and_Lochness): args, Lochness = args_and_Lochness # change subject name keyring = KeyringAndEncrypt(args.outdir) information_to_add_to_metadata = {'box': { 'subject_id': '1001', 'source_id': 'O12341234'}} for study in args.studies: keyring.update_for_box(study) # update box metadata initialize_metadata_test('tmp_lochness/PHOENIX', study, information_to_add_to_metadata) for subject in lochness.read_phoenix_metadata(Lochness): sync(Lochness, subject, dry=False) show_tree_then_delete('tmp_lochness')