示例#1
0
def test_ref_topic(hg_repo_with_content):
    """
    Test trying to update to a topic

    To skip this test (to avoid to install Mercurial and hg-evolve), one can
    use the environment variable REPO2DOCKER_SKIP_HG_TESTS.

    """
    upstream, node_id = hg_repo_with_content
    node_id = subprocess.Popen(
        ["hg", "identify", "-i", "-r", "topic(test-topic)"] +
        args_enabling_topic,
        stdout=subprocess.PIPE,
        cwd=upstream,
    )
    node_id = node_id.stdout.read().decode().strip()

    with TemporaryDirectory() as clone_dir:
        spec = {"repo": upstream, "ref": "test-topic"}
        mercurial = Mercurial()
        for _ in mercurial.fetch(spec, clone_dir):
            pass
        assert (Path(clone_dir) / "test").exists()

        assert mercurial.content_id == node_id
示例#2
0
def test_clone(hg_repo_with_content):
    """Test simple hg clone to a target dir"""
    upstream, node_id = hg_repo_with_content

    with TemporaryDirectory() as clone_dir:
        spec = {"repo": upstream}
        mercurial = Mercurial()
        for _ in mercurial.fetch(spec, clone_dir):
            pass
        assert (Path(clone_dir) / "test").exists()

        assert mercurial.content_id == node_id
示例#3
0
def test_bad_ref(hg_repo_with_content):
    """
    Test trying to update to a ref that doesn't exist
    """
    upstream, node_id = hg_repo_with_content
    with TemporaryDirectory() as clone_dir:
        spec = {"repo": upstream, "ref": "does-not-exist"}
        with pytest.raises(ValueError):
            for _ in Mercurial().fetch(spec, clone_dir):
                pass
示例#4
0
def test_detect_mercurial(hg_repo_with_content, repo_with_content):
    mercurial = Mercurial()
    assert mercurial.detect("this-is-not-a-directory") is None
    assert mercurial.detect(
        "https://github.com/jupyterhub/repo2docker") is None

    git_repo = repo_with_content[0]
    assert mercurial.detect(git_repo) is None

    hg_repo = hg_repo_with_content[0]
    assert mercurial.detect(hg_repo) == {"repo": hg_repo, "ref": None}