def test_reset__reset_local_change_same_owner(self,
                                                  mock_labbook_lfs_disabled,
                                                  mock_config_file):
        """ test reset performs no operation when there's nothing to do """
        username = '******'
        lb = mock_labbook_lfs_disabled[2]
        wf = LabbookWorkflow(lb)
        wf.publish(username=username)
        commit_to_check = lb.git.commit_hash

        # Make some change locally and commit
        fpath = os.path.join(lb.root_dir, 'input', 'testfile')
        with open(fpath, 'w') as f:
            f.write('filedata')
        lb.sweep_uncommitted_changes()
        assert lb.git.commit_hash != commit_to_check

        # Make an UNTRACKED change locally, make sure it gets clared up
        untracked_file = os.path.join(lb.root_dir, 'output', 'untracked-file')
        with open(untracked_file, 'w') as f:
            f.write('untracked data')

        # Do a reset and make sure state resets appropriately
        wf.reset(username=username)
        assert lb.git.commit_hash == commit_to_check
        assert not os.path.exists(fpath)
        assert not os.path.exists(untracked_file)
        remote_hash = call_subprocess('git log -n 1 --oneline'.split(),
                                      cwd=wf.remote).split()[0]
        assert remote_hash in lb.git.commit_hash
 def test_reset__no_op(self, mock_labbook_lfs_disabled, mock_config_file):
     """ test reset performs no operation when there's nothing to do """
     username = '******'
     lb = mock_labbook_lfs_disabled[2]
     wf = LabbookWorkflow(lb)
     wf.reset(username=username)
     wf.publish(username=username)
Exemple #3
0
    def mutate_and_get_payload(cls, root, info, owner, labbook_name, 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():
            wf = LabbookWorkflow(lb)
            wf.reset(username)

        return ResetBranchToRemote(Labbook(id="{}&{}".format(owner, labbook_name),
                                           name=labbook_name, owner=owner))