def mock_create_labbooks(fixture_working_dir): # Create a labbook in the temporary directory config_file = fixture_working_dir[0] im = InventoryManager(fixture_working_dir[0]) lb = im.create_labbook(UT_USERNAME, UT_USERNAME, UT_LBNAME, description="Cats labbook 1") # Create a file in the dir with open(os.path.join(fixture_working_dir[1], 'unittest-examplefile'), 'w') as sf: sf.write("test data") sf.seek(0) FileOperations.insert_file(lb, 'code', sf.name) assert os.path.isfile( os.path.join(lb.root_dir, 'code', 'unittest-examplefile')) # Create test client schema = graphene.Schema(query=LabbookQuery, mutation=LabbookMutations) with patch.object(Configuration, 'find_default_config', lambda self: config_file): app = Flask("lmsrvlabbook") app.config["LABMGR_CONFIG"] = Configuration() app.config["LABMGR_ID_MGR"] = get_identity_manager(Configuration()) with app.app_context(): flask.g.user_obj = app.config["LABMGR_ID_MGR"].get_user_profile() client = Client( schema, middleware=[DataloaderMiddleware(), error_middleware], context_value=ContextMock()) yield lb, client, schema shutil.rmtree(fixture_working_dir, ignore_errors=True)
def test_reflect_deleted_files_on_merge_in(self, mock_create_labbooks): lb, client = mock_create_labbooks[0], mock_create_labbooks[1] with open('/tmp/s1.txt', 'w') as s1: s1.write('original-file\ndata') FileOperations.insert_file(lb, section='code', src_file=s1.name) bm = BranchManager(lb, username=UT_USERNAME) nb = bm.create_branch(f'new-branch') assert os.path.exists(os.path.join(lb.root_dir, 'code', 's1.txt')) FileOperations.delete_files(lb, 'code', ['s1.txt']) assert lb.is_repo_clean assert not os.path.exists(os.path.join(lb.root_dir, 'code', 's1.txt')) bm.workon_branch(bm.workspace_branch) assert os.path.exists(os.path.join(lb.root_dir, 'code', 's1.txt')) merge_q = f""" mutation x {{ mergeFromBranch(input: {{ owner: "{UT_USERNAME}", labbookName: "{UT_LBNAME}", otherBranchName: "{nb}" }}) {{ labbook{{ name description activeBranchName }} }} }} """ r = client.execute(merge_q) assert 'errors' not in r assert r['data']['mergeFromBranch']['labbook']['activeBranchName'] == 'master' assert not os.path.exists(os.path.join(lb.root_dir, 'code', 's1.txt'))
def remote_labbook_repo(): # TODO: Remove after integration tests with LFS support are available conf_file, working_dir = _create_temp_work_dir(lfs_enabled=False) im = InventoryManager(conf_file) lb = im.create_labbook('test', 'test', 'sample-repo-lb', description="my first labbook") bm = BranchManager(lb, username='******') bm.create_branch('testing-branch') #with tempfile.TemporaryDirectory() as tmpdirname: with open(os.path.join('/tmp', 'codefile.c'), 'wb') as codef: codef.write(b'// Cody McCodeface ...') FileOperations.insert_file(lb, "code", "/tmp/codefile.c") assert lb.is_repo_clean bm.workon_branch('master') # Location of the repo to push/pull from yield lb.root_dir shutil.rmtree(working_dir) try: os.remove('/tmp/codefile.c') except: pass
def test_insert_and_make_intermediary_directories(self, mock_labbook, sample_src_file): lb = mock_labbook[2] FO.insert_file(lb, "code", sample_src_file, "/super/random/dir/inside.file") p = os.path.join(lb.root_dir, 'code', "super/random/dir/inside.file") assert os.path.isfile(p)
def test_detail_record_node(self, fixture_working_dir, fixture_test_file): """Test getting an detail record by node ID""" im = InventoryManager(fixture_working_dir[0]) lb = im.create_labbook("default", "default", "labbook1", description="my test description") FileOperations.insert_file(lb, "code", fixture_test_file) # Get activity record to query = """ { labbook(name: "labbook1", owner: "default") { activityRecords { edges{ node{ id commit linkedCommit message type show importance tags detailObjects{ id key type data show importance tags } } } } } } """ result1 = fixture_working_dir[2].execute(query) assert 'errors' not in result1 query = """ {{ node(id: "{}") {{ ... on ActivityDetailObject {{ id key type data show importance tags }} }} }} """.format(result1['data']['labbook']['activityRecords']['edges'][0]['node']['detailObjects'][0]['id']) result2 = fixture_working_dir[2].execute(query) assert 'errors' not in result2 assert result2['data']['node'] == result1['data']['labbook']['activityRecords']['edges'][0]['node']['detailObjects'][0]
def test_import_labbook(self, fixture_working_dir): """Test batch uploading, but not full import""" class DummyContext(object): def __init__(self, file_handle): self.labbook_loader = None self.files = {'uploadChunk': file_handle} client = Client(fixture_working_dir[3], middleware=[DataloaderMiddleware()]) # Create a temporary labbook lb = InventoryManager(fixture_working_dir[0]).create_labbook("default", "default", "test-export", description="Tester") # Create a largeish file in the dir with open(os.path.join(fixture_working_dir[1], 'testfile.bin'), 'wb') as testfile: testfile.write(os.urandom(9000000)) FileOperations.insert_file(lb, 'input', testfile.name) # Export labbook zip_file = export_labbook_as_zip(lb.root_dir, tempfile.gettempdir()) lb_dir = lb.root_dir # Get upload params chunk_size = 4194304 file_info = os.stat(zip_file) file_size = int(file_info.st_size / 1000) total_chunks = int(math.ceil(file_info.st_size/chunk_size)) with open(zip_file, 'rb') as tf: for chunk_index in range(total_chunks): chunk = io.BytesIO() chunk.write(tf.read(chunk_size)) chunk.seek(0) file = FileStorage(chunk) query = f""" mutation myMutation{{ importLabbook(input:{{ chunkUploadParams:{{ uploadId: "jfdjfdjdisdjwdoijwlkfjd", chunkSize: {chunk_size}, totalChunks: {total_chunks}, chunkIndex: {chunk_index}, fileSize: "{file_size}", filename: "{os.path.basename(zip_file)}" }} }}) {{ importJobKey }} }} """ result = client.execute(query, context_value=DummyContext(file)) assert "errors" not in result if chunk_index == total_chunks - 1: assert type(result['data']['importLabbook']['importJobKey']) == str assert "rq:job:" in result['data']['importLabbook']['importJobKey'] chunk.close()
def test_move_loaded_directory_with_full_tree(self, mock_labbook, mock_config_file, sample_src_file): lb = mock_labbook[2] FO.makedir(lb, 'code/level_1/level_2A', create_activity_record=True) FO.makedir(lb, 'code/level_1/level_2B', create_activity_record=True) FO.makedir(lb, 'code/target_dir', create_activity_record=True) FO.makedir(lb, 'code/target_dir/existing_dir_counted_anyway', create_activity_record=True) FO.makedir(lb, 'code/this-dir-must-be-ignored', create_activity_record=True) FO.insert_file(lb, 'code', sample_src_file, dst_path='level_1/level_2B') # Move "level_1" into target_dir results = FO.move_file(lb, 'code', 'level_1', 'target_dir') assert len(results) == 4
def mock_create_labbooks(fixture_working_dir): # Create a labbook in the temporary directory lb = InventoryManager(fixture_working_dir[0]).create_labbook( "default", "default", "sample-repo-lb", description="Cats labbook 1") # Create a file in the dir with open(os.path.join(fixture_working_dir[1], 'codefile.c'), 'w') as sf: sf.write("1234567") sf.seek(0) FileOperations.insert_file(lb, 'code', sf.name) assert os.path.isfile(os.path.join(lb.root_dir, 'code', 'codefile.c')) # name of the config file, temporary working directory, the schema yield fixture_working_dir, lb
def test_walkdir_with_favorites(self, mock_labbook, sample_src_file): lb = mock_labbook[2] dirs = ["code/cat_dir", "code/dog_dir"] for d in dirs: FO.makedir(lb, d) sfile = '/tmp/testwalkdirwithfavorites.file' for d in ['', 'dog_dir', 'cat_dir']: open(sfile, 'w').write('xxx') FO.insert_file(lb, 'code', sfile, d) sample_filename = os.path.basename(sfile) # Since the file is in a hidden directory, it should not be found. dir_walks = FO.walkdir(lb, 'code') # Spot check some entries assert len(dir_walks) == 5 assert dir_walks[0]['key'] == 'cat_dir/' assert dir_walks[0]['is_dir'] is True assert dir_walks[0]['is_favorite'] is False assert dir_walks[1]['key'] == 'dog_dir/' assert dir_walks[1]['is_dir'] is True assert dir_walks[1]['is_favorite'] is False assert dir_walks[2]['is_favorite'] is False assert dir_walks[2]['is_dir'] is False assert dir_walks[3]['is_favorite'] is False assert dir_walks[3]['is_dir'] is False assert dir_walks[4]['is_favorite'] is False assert dir_walks[4]['is_dir'] is False lb.create_favorite("code", sample_filename, description="Fav 1") lb.create_favorite("code", f"dog_dir/{sample_filename}", description="Fav 2") lb.create_favorite("code", f"cat_dir/", description="Fav 3", is_dir=True) dir_walks = FO.walkdir(lb, 'code') # Spot check some entries assert len(dir_walks) == 5 assert dir_walks[0]['key'] == 'cat_dir/' assert dir_walks[0]['is_dir'] is True assert dir_walks[0]['is_favorite'] is True assert dir_walks[1]['key'] == 'dog_dir/' assert dir_walks[1]['is_dir'] is True assert dir_walks[1]['is_favorite'] is False assert dir_walks[2]['is_favorite'] is True assert dir_walks[2]['is_dir'] is False assert dir_walks[3]['is_favorite'] is False assert dir_walks[3]['is_dir'] is False assert dir_walks[4]['is_favorite'] is True assert dir_walks[4]['is_dir'] is False
def test_walkdir(self, mock_labbook): lb = mock_labbook[2] dirs = [ "code/cat_dir", "code/dog_dir", "code/mouse_dir/", "code/mouse_dir/new_dir", "code/.hidden_dir" ] for d in dirs: FO.makedir(lb, d) for d in ['.hidden_dir/', '', 'dog_dir', 'mouse_dir/new_dir/']: open('/tmp/myfile.c', 'w').write('data') FO.insert_file(lb, 'code', '/tmp/myfile.c', d) dir_walks_hidden = FO.walkdir(lb, 'code', show_hidden=True) assert any([ os.path.basename('/tmp/myfile.c') in d['key'] for d in dir_walks_hidden ]) assert not any( ['.git' in d['key'].split(os.path.sep) for d in dir_walks_hidden]) assert not any(['.gigantum' in d['key'] for d in dir_walks_hidden]) assert all([d['key'][0] != '/' for d in dir_walks_hidden]) # Spot check some entries assert len(dir_walks_hidden) == 15 assert dir_walks_hidden[0]['key'] == '.hidden_dir/' assert dir_walks_hidden[0]['is_dir'] is True assert dir_walks_hidden[3]['key'] == 'mouse_dir/' assert dir_walks_hidden[3]['is_dir'] is True assert dir_walks_hidden[6]['key'] == '.hidden_dir/.gitkeep' assert dir_walks_hidden[6]['is_dir'] is False assert dir_walks_hidden[13]['key'] == 'mouse_dir/new_dir/.gitkeep' assert dir_walks_hidden[13]['is_dir'] is False # Since the file is in a hidden directory, it should not be found. dir_walks = FO.walkdir(lb, 'code') # Spot check some entries assert len(dir_walks) == 7 assert dir_walks[0]['key'] == 'cat_dir/' assert dir_walks[0]['is_dir'] is True assert dir_walks[1]['key'] == 'dog_dir/' assert dir_walks[1]['is_dir'] is True assert dir_walks[2]['key'] == 'mouse_dir/' assert dir_walks[2]['is_dir'] is True assert dir_walks[3]['is_dir'] is False assert dir_walks[4]['is_dir'] is False assert dir_walks[5]['is_dir'] is True assert dir_walks[5]['key'] == 'mouse_dir/new_dir/' assert dir_walks[6]['is_dir'] is False
def mock_create_labbooks_no_lfs(fixture_working_dir_lfs_disabled): # Create a labbook in the temporary directory im = InventoryManager(fixture_working_dir_lfs_disabled[0]) lb = im.create_labbook("default", "default", "labbook1", description="Cats labbook 1") # Create a file in the dir with open(os.path.join(fixture_working_dir_lfs_disabled[1], 'sillyfile'), 'w') as sf: sf.write("1234567") sf.seek(0) FileOperations.insert_file(lb, 'code', sf.name) assert os.path.isfile(os.path.join(lb.root_dir, 'code', 'sillyfile')) # name of the config file, temporary working directory, the schema yield fixture_working_dir_lfs_disabled
def test_insert_file_success_1(self, mock_labbook, sample_src_file): lb = mock_labbook[2] new_file_data = FO.insert_file(lb, "code", sample_src_file) base_name = os.path.basename(sample_src_file) assert os.path.exists(os.path.join(lb.root_dir, 'code', base_name)) assert new_file_data['key'] == f'{base_name}' assert new_file_data['is_dir'] is False
def test_move_loaded_directory_with_one_file(self, mock_labbook, mock_config_file, sample_src_file): lb = mock_labbook[2] new_file_data = FO.insert_file(lb, "code", sample_src_file) base_name = os.path.basename(new_file_data['key']) assert os.path.exists(os.path.join(lb.root_dir, 'code', base_name)) # make new subdir os.makedirs(os.path.join(lb.root_dir, 'code', 'subdir')) # .. and then put a file in it mv_file_res = FO.move_file(lb, "code", base_name, os.path.join('subdir', base_name)) # Should be 2, because it returns the info of the directory it was moved into assert len(mv_file_res) == 1 assert mv_file_res[0]['key'] == f'subdir/{base_name}' assert mv_file_res[0]['is_dir'] == False # Move "subdir" into "target_dir", there should be two activity records FO.makedir(lb, "code/target_dir", create_activity_record=True) mv_dir_res = FO.move_file(lb, "code", 'subdir', 'target_dir') assert len(mv_dir_res) == 2 assert mv_dir_res[0]['key'] == 'target_dir/subdir/' assert mv_dir_res[0]['is_dir'] is True assert mv_dir_res[1]['key'] == f'target_dir/subdir/{base_name}' assert mv_dir_res[1]['is_dir'] is False assert not os.path.exists(os.path.join(lb.root_dir, 'code', 'subdir')) assert os.path.exists(os.path.join(lb.root_dir, 'code', 'target_dir/subdir'))
def test_remove_file_success(self, mock_labbook, sample_src_file): lb = mock_labbook[2] new_file_data = FO.insert_file(lb, "code", sample_src_file) base_name = os.path.basename(new_file_data['key']) assert os.path.exists(os.path.join(lb.root_dir, 'code', base_name)) FO.delete_files(lb, 'code', [base_name]) assert not os.path.exists(os.path.join(lb.root_dir, 'code', base_name))
def test_insert_file_success_2(self, mock_labbook, sample_src_file): lb = mock_labbook[2] FO.makedir(lb, "output/testdir") new_file_data = FO.insert_file(lb, "output", sample_src_file, "testdir") base_name = os.path.basename(new_file_data['key']) assert os.path.exists(os.path.join(lb.root_dir, 'output', 'testdir', base_name)) assert new_file_data['key'] == f'testdir/{base_name}' assert new_file_data['is_dir'] is False
def test_remove_file_fail_old_prototype(self, mock_labbook, sample_src_file): lb = mock_labbook[2] new_file_data = FO.insert_file(lb, "code", sample_src_file) base_name = os.path.basename(new_file_data['key']) assert os.path.exists(os.path.join(lb.root_dir, 'code', base_name)) with pytest.raises(ValueError): FO.delete_files(lb, 'code', base_name)
def test_move_single_file(self, mock_labbook, mock_config_file, sample_src_file): lb = mock_labbook[2] f = FO.insert_file(lb, 'code', sample_src_file)['key'] FO.makedir(lb, 'code/target_dir') results = FO.move_file(lb, 'code', f, 'target_dir') assert len(results) == 1 pprint.pprint(results) assert results[0]['is_dir'] == False assert results[0]['key'] == 'target_dir/' + os.path.basename(sample_src_file)
def test_move_single_file_to_section_top(self, mock_labbook, mock_config_file, sample_src_file): lb = mock_labbook[2] FO.makedir(lb, 'code/inner_dir') f = FO.insert_file(lb, 'code', sample_src_file, 'inner_dir')['key'] # Move file to top of code section results = FO.move_file(lb, 'code', f, dst_rel_path='') # Results should be returned for "code" -- the file just moved there and the assert len(results) == 1 assert results[0]['is_dir'] == False assert results[0]['key'] == os.path.basename(f)
def test_remove_dir(self, mock_labbook, sample_src_file): lb = mock_labbook[2] FO.makedir(lb, "output/testdir") new_file_path = FO.insert_file(lb, "output", sample_src_file, "testdir") base_name = os.path.basename(new_file_path['key']) assert os.path.exists(os.path.join(lb.root_dir, 'output', 'testdir', base_name)) # Note! Now that remove() uses force=True, no special action is needed for directories. # Delete the directory FO.delete_files(lb, "output", ["testdir"]) assert not os.path.exists(os.path.join(lb.root_dir, 'output', 'testdir', base_name)) assert not os.path.exists(os.path.join(lb.root_dir, 'output', 'testdir'))
def test_remove_empty_dir(self, mock_labbook, sample_src_file): lb = mock_labbook[2] FO.makedir(lb, "output/testdir") new_file_path = FO.insert_file(lb, "output", sample_src_file, "testdir") base_name = os.path.basename(new_file_path['key']) assert os.path.exists(os.path.join(lb.root_dir, 'output', 'testdir', base_name)) # Delete the directory FO.delete_files(lb, "output", ["testdir"]) assert not os.path.exists(os.path.join(lb.root_dir, 'output', 'testdir', base_name)) assert not os.path.exists(os.path.join(lb.root_dir, 'output', 'testdir'))
def test_conflicted_merge_from_no_force_fail(self, mock_create_labbooks): lb, client = mock_create_labbooks[0], mock_create_labbooks[1] with open('/tmp/s1.txt', 'w') as s1: s1.write('original-file\ndata') FileOperations.insert_file(lb, section='code', src_file=s1.name) bm = BranchManager(lb, username=UT_USERNAME) nb = bm.create_branch(f'new-branch') with open('/tmp/s1.txt', 'w') as s1: s1.write('branch-conflict-data') FileOperations.insert_file(lb, section='code', src_file=s1.name) bm.workon_branch(bm.workspace_branch) with open('/tmp/s1.txt', 'w') as s1: s1.write('mainline-conflict-data') FileOperations.insert_file(lb, section='code', src_file=s1.name) merge_q = f""" mutation x {{ mergeFromBranch(input: {{ owner: "{UT_USERNAME}", labbookName: "{UT_LBNAME}", otherBranchName: "{nb}" }}) {{ labbook{{ name description activeBranchName }} }} }} """ r = client.execute(merge_q) assert 'errors' in r assert 'Merge conflict' in r['errors'][0]['message']
def test_insert_file_upload_id(self, mock_labbook): lb = mock_labbook[2] test_file = os.path.join(tempfile.gettempdir(), "asdfasdf-testfile.txt") with open(test_file, 'wt') as sample_f: # Fill sample file with some deterministic crap sample_f.write("n4%nm4%M435A EF87kn*C" * 40) # This is basically checking for rename new_file_data = FO.insert_file(lb, "code", test_file, "testfile.txt") assert os.path.exists(os.path.join(lb.root_dir, 'code', 'testfile.txt')) assert new_file_data['key'] == 'testfile.txt' assert new_file_data['is_dir'] is False
def test_move_file_as_rename_in_same_dir(self, mock_labbook, sample_src_file): lb = mock_labbook[2] # insert file new_file_data = FO.insert_file(lb, "code", sample_src_file, '') base_name = os.path.basename(new_file_data['key']) assert os.path.exists(os.path.join(lb.root_dir, 'code', base_name)) assert new_file_data['key'] == base_name # move to rename moved_rel_path = os.path.join(f'{base_name}.MOVED') r = FO.move_file(lb, 'code', new_file_data['key'], moved_rel_path) assert len(r) == 1 assert not os.path.exists(os.path.join(lb.root_dir, 'code', base_name)) assert os.path.exists(os.path.join(lb.root_dir, 'code', f'{base_name}.MOVED')) assert os.path.isfile(os.path.join(lb.root_dir, 'code', f'{base_name}.MOVED'))
def test_merge_conflict_basic(self, mock_labbook_lfs_disabled): """ Test a basic merge-conflict scenario with a conflict on one file. First, assert that a MergeConflict is raised when the conflict is detected Second, test the force flag to overwrite the conflict using the incoming branch.""" lb = mock_labbook_lfs_disabled[2] # Insert a text file into the master branch of lb with open('/tmp/s1.txt', 'w') as s1: s1.write('original-file\ndata') FileOperations.insert_file(lb, section='code', src_file=s1.name) # Create a new branch from this point and make a change to s1.txt bm = BranchManager(lb, username=TEST_USER) feature_name = bm.create_branch("example-feature-branch") with open('/tmp/s1.txt', 'w') as s1: s1.write('new-changes-in\nfeature-branch') FileOperations.insert_file(lb, section='code', src_file=s1.name) # Switch back to the main branch and make a new, conflicting change. bm.workon_branch(bm.workspace_branch) assert lb.is_repo_clean assert not os.path.exists(os.path.join(lb.root_dir, 'output/sample')) with open('/tmp/s1.txt', 'w') as s1: s1.write('upstream-changes-from-workspace') FileOperations.insert_file(lb, section='code', src_file=s1.name, dst_path='') # Switch back to feature branch -- make sure that failed merges rollback to state before merge. bm.workon_branch(feature_name) cp = bm.repository.git.commit_hash try: bm.merge_from(bm.workspace_branch) assert False, "merge_from should have thrown conflict" except MergeConflict as m: # Assert that the conflicted file(s) are as expected assert m.file_conflicts == ['code/s1.txt'] assert lb.is_repo_clean # Now try to force merge, and changes are taken from the workspace-branch bm.merge_use_ours(bm.workspace_branch) assert open(os.path.join(lb.root_dir, 'code', 's1.txt')).read(1000) == \ 'new-changes-in\nfeature-branch' assert lb.is_repo_clean # Reset this branch call_subprocess(f'git reset --hard {cp}'.split(), cwd=bm.repository.root_dir) bm.merge_use_theirs(bm.workspace_branch) assert open(os.path.join(lb.root_dir, 'code', 's1.txt')).read(1000) == \ 'upstream-changes-from-workspace' assert lb.is_repo_clean
def test_get_recent_activity(self, fixture_working_dir, snapshot, fixture_test_file): """Test paging through activity records""" im = InventoryManager(fixture_working_dir[0]) lb = im.create_labbook("default", "default", "labbook11", description="my test description", author=GitAuthor(name="tester", email="*****@*****.**")) FileOperations.insert_file(lb, "code", fixture_test_file) # fake activity store = ActivityStore(lb) adr1 = ActivityDetailRecord(ActivityDetailType.CODE) adr1.show = False adr1.importance = 100 adr1.add_value("text/plain", "first") ar = ActivityRecord(ActivityType.CODE, show=False, message="ran some code", importance=50, linked_commit="asdf") ar.add_detail_object(adr1) # Create Activity Record store.create_activity_record(ar) store.create_activity_record(ar) store.create_activity_record(ar) store.create_activity_record(ar) open('/tmp/test_file.txt', 'w').write("xxx" * 50) FileOperations.insert_file(lb, "input", '/tmp/test_file.txt') FileOperations.makedir(lb, "input/test") open('/tmp/test_file.txt', 'w').write("xxx" * 50) FileOperations.insert_file(lb, "input", '/tmp/test_file.txt', "test") FileOperations.makedir(lb, "input/test2") open('/tmp/test_file.txt', 'w').write("xxx" * 50) FileOperations.insert_file(lb, "input", '/tmp/test_file.txt', "test2") store.create_activity_record(ar) store.create_activity_record(ar) store.create_activity_record(ar) store.create_activity_record(ar) store.create_activity_record(ar) open('/tmp/test_file.txt', 'w').write("xxx" * 50) FileOperations.insert_file(lb, "output", '/tmp/test_file.txt') # Get all records at once with no pagination args and verify cursors look OK directly query = """ { labbook(owner: "default", name: "labbook11") { overview { recentActivity { message type show importance tags } } } } """ snapshot.assert_match(fixture_working_dir[2].execute(query))
def test_remove_file_fail(self, mock_labbook, sample_src_file): lb = mock_labbook[2] FO.insert_file(lb, "code", sample_src_file) new_file_path = os.path.join('blah', 'invalid.txt') with pytest.raises(ValueError): FO.delete_files(lb, 'code', [new_file_path])