Ejemplo n.º 1
0
def test_get_git_environ_adjusted():
    gitrunner = GitWitlessRunner()
    env = {
        "GIT_DIR": "../../.git",
        "GIT_WORK_TREE": "../../",
        "TEST_VAR": "Exists"
    }

    # test conversion of relevant env vars from relative_path to correct absolute_path
    adj_env = gitrunner.get_git_environ_adjusted(env)
    assert_equal(adj_env["GIT_DIR"], abspath(env["GIT_DIR"]))
    assert_equal(adj_env["GIT_WORK_TREE"], abspath(env["GIT_WORK_TREE"]))

    # test if other environment variables passed to function returned unaltered
    assert_equal(adj_env["TEST_VAR"], env["TEST_VAR"])

    # test import of sys_env if no environment passed to function
    sys_env = gitrunner.get_git_environ_adjusted()
    assert_equal(sys_env["PWD"], os.environ.get("PWD"))
Ejemplo n.º 2
0
def test_gitannex(osf_id, dspath):
    from datalad.cmd import GitWitlessRunner
    dspath = Path(dspath)

    ds = Dataset(dspath).create()

    # add remote parameters here
    init_remote_opts = ["node={}".format(osf_id)]

    # add special remote
    init_opts = common_init_opts + init_remote_opts
    ds.repo.init_remote('osfproject', options=init_opts)

    # run git-annex-testremote
    # note, that we don't want to capture output. If something goes wrong we
    # want to see it in test build's output log.
    # TODO use AnnexRepo._call_annex(..., protocol=None) with 0.14+
    GitWitlessRunner(cwd=dspath,
                     env=GitWitlessRunner.get_git_environ_adjusted()).run([
                         'git', 'annex', 'testremote', 'osfproject', "--fast"
                     ])