def test_fail_remove_branch_on_active_branch(self, mock_labbook_lfs_disabled): """ Test remove branch does raises exception when deleting current branch """ lb = mock_labbook_lfs_disabled[2] bm = BranchManager(lb, username=TEST_USER) with pytest.raises(BranchException): bm.remove_branch(bm.active_branch)
def migrate_labbook_branches(labbook: LabBook) -> None: bm = BranchManager(labbook) if 'gm.workspace' not in bm.active_branch: raise ValueError('Can only migrate branches if active branch contains' '"gm.workspace"') master_branch = 'master' if master_branch in bm.branches_local: bm.remove_branch(master_branch) bm.create_branch(master_branch)
def mutate_and_get_payload(cls, root, info, owner, labbook_name, branch_name, delete_local=False, delete_remote=False, client_mutation_id=None): username = get_logged_in_username() lb = InventoryManager().load_labbook(username, owner, labbook_name, author=get_logged_in_author()) with lb.lock(): bm = BranchManager(lb, username=username) if delete_local: bm.remove_branch(target_branch=branch_name) if delete_remote: bm.remove_remote_branch(target_branch=branch_name) return DeleteExperimentalBranch(Labbook(id="{}&{}".format(owner, labbook_name), name=labbook_name, owner=owner))
def test_success_remove_branch(self, mock_labbook_lfs_disabled): """ Test that branches can be removed locally """ lb = mock_labbook_lfs_disabled[2] bm = BranchManager(lb, username=TEST_USER) t = 'branch-to-make-and-then-delete' branch_name_to_delete = bm.create_branch(title=t) assert branch_name_to_delete in bm.branches_local bm.workon_branch(bm.workspace_branch) bm.remove_branch(branch_name_to_delete) assert branch_name_to_delete not in bm.branches_local
def test_fail_remove_branch_not_exist(self, mock_labbook_lfs_disabled): """ Test remove branch does raises exception when deleting nonexisting branch """ lb = mock_labbook_lfs_disabled[2] bm = BranchManager(lb, username=TEST_USER) with pytest.raises(InvalidBranchName): bm.remove_branch('branch-that-does-not-exist')