Esempio n. 1
0
def test_negative_git():
    """
    test negative git command
    """
    try:
        git("blah")
    except Exception as ex:
        assert not isinstance(ex, NotGitRepoError)
Esempio n. 2
0
def test_NotGitRepoError():
    """
    NotGitRepoError
    """
    with cd(NON_GIT_REPO_PATH):
        try:
            git("rev-parse", "HEAD")
            result = False
        except NotGitRepoError:
            result = True
    assert result
Esempio n. 3
0
def test_APP_REVISION():
    """
    version
    """
    assert CFG.APP_REVISION == git("rev-parse", "HEAD")
    with cd(NON_GIT_REPO_PATH):
        os.environ["APP_REVISION"] = "APP_REVISION"
        assert CFG.APP_REVISION == "APP_REVISION"
Esempio n. 4
0
def test_APP_BRANCH():
    """
    branch
    """
    assert CFG.APP_BRANCH == git("rev-parse", "--abbrev-ref", "HEAD")
    with cd(NON_GIT_REPO_PATH):
        os.environ["APP_BRANCH"] = "APP_BRANCH"
        assert CFG.APP_BRANCH == "APP_BRANCH"
Esempio n. 5
0
def test_APP_VERSION():
    """
    version
    """
    assert CFG.APP_VERSION == git("describe", "--abbrev=7", "--always")
    with cd(NON_GIT_REPO_PATH):
        os.environ["APP_VERSION"] = "APP_VERSION"
        assert CFG.APP_VERSION == "APP_VERSION"
Esempio n. 6
0
def test_APP_REMOTE_ORIGIN_URL():
    """
    remote origin url
    """
    assert CFG.APP_REMOTE_ORIGIN_URL == git("config --get remote.origin.url")
    with cd(NON_GIT_REPO_PATH):
        os.environ["APP_REMOTE_ORIGIN_URL"] = "APP_REMOTE_ORIGIN_URL"
        assert CFG.APP_REMOTE_ORIGIN_URL == "APP_REMOTE_ORIGIN_URL"
Esempio n. 7
0
def test_BRANCH():
    """
    branch
    """
    assert CFG.BRANCH == git("rev-parse --abbrev-ref HEAD")
    with cd(NON_GIT_REPO_PATH):
        os.environ["BRANCH"] = "BRANCH"
        assert CFG.BRANCH == "BRANCH"
Esempio n. 8
0
def test_APP_LS_REMOTE():
    """
    ls-remote
    """
    result = git("ls-remote", f"https://github.com/{CFG.APP_REPONAME}")
    assert CFG.APP_LS_REMOTE == {
        refname: revision
        for revision, refname in [line.split() for line in result.split("\n")]
    }
    with cd(NON_GIT_REPO_PATH):
        try:
            os.environ["APP_REPONAME"] = "mozilla/subhub"
            CFG.APP_LS_REMOTE
            assert False
        except Exception as ex:
            assert isinstance(ex, NotGitRepoError)
Esempio n. 9
0
def test_APP_REPOROOT():
    """
    reporoot
    """
    assert CFG.APP_REPOROOT == git("rev-parse", "--show-toplevel")
Esempio n. 10
0
def test_REPO_ROOT():
    """
    repo_root
    """
    assert CFG.REPO_ROOT == git("rev-parse --show-toplevel")