def test_negative_git(): """ test negative git command """ try: git("blah") except Exception as ex: assert not isinstance(ex, NotGitRepoError)
def test_NotGitRepoError(): """ NotGitRepoError """ with cd(NON_GIT_REPO_PATH): try: git("rev-parse", "HEAD") result = False except NotGitRepoError: result = True assert result
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"
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"
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"
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"
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"
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)
def test_APP_REPOROOT(): """ reporoot """ assert CFG.APP_REPOROOT == git("rev-parse", "--show-toplevel")
def test_REPO_ROOT(): """ repo_root """ assert CFG.REPO_ROOT == git("rev-parse --show-toplevel")