Пример #1
0
def test_get_origin_line(test_input, expected):
    remote_string = test_input
    origin_line = GitOpen.get_origin_line(remote_string)
    assert origin_line == expected
    # Test an empty string (no remotes)
    with pytest.raises(SystemExit):
        origin_line = GitOpen.get_origin_line("")
        assert origin_line is None
Пример #2
0
def test_add_commit_to_url__method():
    with patch.object(GitOpen,
                      "get_current_commit_hash",
                      return_value="MOCKED_HASH"):
        git_repo = GitOpen()
        git_repo.add_commit_to_url()
        assert (git_repo.url ==
                "https://github.com/cfarvidson/git-open/commit/MOCKED_HASH")
Пример #3
0
def test_get_hash__method():
    hash = GitOpen().get_current_commit_hash()
    assert len(hash) == 40
Пример #4
0
def test_filter_origin_line(test_input, expected):
    assert GitOpen.filter_origin_line(test_input) == expected
Пример #5
0
def test_make_url_exception(test_input):
    with pytest.raises(NotImplementedError):
        GitOpen.make_url(test_input)
Пример #6
0
def test_make_url(test_input, expected):
    assert GitOpen.make_url(test_input) == expected
Пример #7
0
def test_get_branch_method():
    with patch.object(sh, "git", return_value="MOCKED_BRANCH"):
        branch = GitOpen.get_current_branch()
        assert branch == "MOCKED_BRANCH"