Beispiel #1
0
    def test_invalid_commit_id():
        with pytest.raises(ValueError) as exception_info:
            with Gitget(repository="https://github.com/simonkowallik/ihac",
                        commit="1234567") as gitrepo:
                print(gitrepo.info)

        assert exception_info.type is ValueError
Beispiel #2
0
    def test_non_existing_commit():
        with pytest.raises(GitgetException) as exception_info:
            with Gitget(repository="https://github.com/simonkowallik/ihac",
                        commit=40 * "1") as gitrepo:
                print(gitrepo.info)

        assert exception_info.type is GitgetException
Beispiel #3
0
 def test_full_clone():
     with Gitget(
             repository="https://github.com/simonkowallik/as3ninjaDemo",
             commit="924f79f8569317d01d1be7d6a77ac8e2b88332ff",
             depth=0,
     ) as gitrepo:
         assert isinstance(gitrepo.info, dict)
Beispiel #4
0
 def test_Gitget_tag():
     with Gitget(
             repository="https://github.com/simonkowallik/as3ninjaDemo",
             branch="tag_v1.0",
     ) as gitrepo:
         assert isinstance(gitrepo.info, dict)
         assert gitrepo.info["branch"] == "tag_v1.0"
Beispiel #5
0
 def test_Gitget_depth0():
     with Gitget(
             repository="https://github.com/simonkowallik/as3ninjaDemo",
             branch="master",
             depth=0,
     ) as gitrepo:
         assert isinstance(gitrepo.info, dict)
         assert gitrepo.info["branch"] == "master"
Beispiel #6
0
    def test_TimeoutExpired():
        """test TimeoutExpired is raised when an operation takes too long."""
        with pytest.raises(GitgetException) as exception_info:
            with Gitget(
                    repository="https://github.com/python/cpython") as gitrepo:
                print(gitrepo.info)

        assert exception_info.type is GitgetException
        assert "TimeoutExpired" in str(exception_info.value)
Beispiel #7
0
    def test_non_existing_repository():
        """test a non-existing repository"""
        with pytest.raises(GitgetException) as exception_info:
            with Gitget(
                    repository="https://github.com/repository-does-not-exist"
            ) as gitrepo:
                print(gitrepo.info)

        assert exception_info.type is GitgetException
Beispiel #8
0
    def test_Gitget_depth_negative():
        with pytest.raises(ValueError) as exception_info:
            with Gitget(
                    repository="https://github.com/simonkowallik/ihac",
                    branch="master",
                    depth=-1,
            ) as gitrepo:
                print(gitrepo.info)

        assert exception_info.type is ValueError
Beispiel #9
0
    def test_commit_missing_in_clone():
        with pytest.raises(GitgetException) as exception_info:
            with Gitget(
                    repository="https://github.com/simonkowallik/as3ninjaDemo",
                    commit="924f79f8569317d01d1be7d6a77ac8e2b88332ff",
                    depth=3,
            ) as gitrepo:
                print(gitrepo.info)

        assert exception_info.type is GitgetException
Beispiel #10
0
    def test_non_existing_repository():
        # TODO: this prompts for user+password. requires credential handling
        with pytest.raises(GitgetException) as exception_info:
            with Gitget(
                    repository=
                    "https://github.com/simonkowallik/does-not-exist",
                    branch="doesnt-exist",
            ) as gitrepo:
                print(gitrepo.info)

        assert exception_info.type is GitgetException
Beispiel #11
0
    def test_custom_repodir_2ndclone_force(fixture_tmpdir):
        repodir = fixture_tmpdir
        # first clone
        with Gitget(
                repository="https://github.com/simonkowallik/ihac",
                branch="master",
                repodir=repodir,
        ) as gitrepo:
            assert isinstance(gitrepo.info, dict)
            assert gitrepo.info["branch"] == "master"

        # second clone to existing repo
        with Gitget(
                repository="https://github.com/simonkowallik/ihac",
                branch="master",
                repodir=repodir,
                force=True,
        ) as gitrepo:
            assert isinstance(gitrepo.info, dict)
            assert gitrepo.info["branch"] == "master"
Beispiel #12
0
    def test_custom_repodir(fixture_tmpdir):
        repodir = fixture_tmpdir
        with Gitget(
                repository="https://github.com/simonkowallik/ihac",
                branch="master",
                repodir=repodir,
        ) as gitrepo:
            assert isinstance(gitrepo.info, dict)
            assert gitrepo.info["branch"] == "master"

        assert Path(repodir).exists()
Beispiel #13
0
    def test_custom_repodir_2ndclone_noforce(fixture_tmpdir):
        repodir = fixture_tmpdir
        # first clone
        with Gitget(
                repository="https://github.com/simonkowallik/ihac",
                branch="master",
                repodir=repodir,
        ) as gitrepo:
            assert isinstance(gitrepo.info, dict)
            assert gitrepo.info["branch"] == "master"

        # second clone to existing repo without force raises exception
        with pytest.raises(GitgetException) as exception_info:
            with Gitget(
                    repository="https://github.com/simonkowallik/ihac",
                    branch="master",
                    repodir=repodir,
            ) as gitrepo:
                print(gitrepo.info)

        assert exception_info.type is GitgetException
Beispiel #14
0
    def test_rmrepodir(fixture_tmpdir):
        repodir = fixture_tmpdir
        with Gitget(
                repository="https://github.com/simonkowallik/as3ninjaDemo",
                branch="master",
                repodir=repodir,
        ) as gitrepo:
            assert isinstance(gitrepo.info, dict)
            assert gitrepo.info["branch"] == "master"
            gitrepo.rmrepodir()

        assert Path(repodir).exists() is False
Beispiel #15
0
    def test_private_repository():
        """test a private repository requiring authentication.
        This test will prompt for credentials if not authenticated and will run into a timeout.
        """
        with pytest.raises(GitgetException) as exception_info:
            with Gitget(
                    repository=
                    "https://github.com/simonkowallik/some-private-repository"
            ) as gitrepo:
                print(gitrepo.info)

        assert exception_info.type is GitgetException
        assert "CalledProcessError" in str(exception_info.value)
Beispiel #16
0
 def test_Gitget_tag():
     with Gitget(repository="https://github.com/simonkowallik/ihac",
                 branch="2.0") as gitrepo:
         assert isinstance(gitrepo.info, dict)
         assert gitrepo.info["branch"] == "2.0"
Beispiel #17
0
 def test_Gitget_repo_only():
     with Gitget(
             repository="https://github.com/simonkowallik/ihac") as gitrepo:
         assert isinstance(gitrepo.info, dict)
         assert gitrepo.info["branch"] == "master"
Beispiel #18
0
 def test_dir_exists_on_with():
     with Gitget(
             repository="https://github.com/simonkowallik/ihac") as gitrepo:
         assert Path(gitrepo.repodir + "/.git").exists()
Beispiel #19
0
 def test_commit_within_depth20():
     """Test that a depth of 20 is used instead of the default depth of 1"""
     with Gitget(repository="https://github.com/simonkowallik/as3ninjaDemo",
                 commit="HEAD~19") as gitrepo:
         assert isinstance(gitrepo.info, dict)
Beispiel #20
0
 def test_commit_head_tilde2():
     """Test HEAD~<int> syntax works"""
     with Gitget(repository="https://github.com/simonkowallik/as3ninjaDemo",
                 commit="HEAD~2") as gitrepo:
         assert isinstance(gitrepo.info, dict)