def test_polytime_BAD_no_git_cmd(ok_repo, monkeypatch, today):
    monkeypatch.setenv('PATH', '')

    with pytest.raises(FileNotFoundError):
        pvlib.polytime(basepath=ok_repo)
    d = pvlib.polytime(no_raise=True, basepath=ok_repo)
    assert d.startswith(today)
def test_polyversion_BAD_env_var(no_repo, empty_repo, untagged_repo,
                                 monkeypatch):
    monkeypatch.setenv('foo_VERSION', '1.2.3')
    root = (no_repo / '/')

    for repo in [no_repo, empty_repo, untagged_repo]:
        root.chdir()
        assert pvlib.polyversion(pname='foo', basepath=repo) == '1.2.3'
        pvlib.polytime(pname='foo', basepath=repo)

        repo.chdir()
        assert pvlib.polyversion(pname='foo') == '1.2.3'
        pvlib.polytime(pname='foo', basepath=repo)
def test_polytime_p1(ok_repo, untagged_repo, no_repo, today):
    ## OK REPO

    d = pvlib.polytime(basepath=ok_repo)
    assert d.startswith(today)
    d = pvlib.polytime(no_raise=True, basepath=ok_repo)
    assert d.startswith(today)

    ## UNTAGGED REPO

    pvlib.polytime(basepath=untagged_repo)
    assert d.startswith(today)
    d = pvlib.polytime(no_raise=True, basepath=untagged_repo)
    assert d.startswith(today)

    ## NO REPO

    with pytest.raises(sbp.CalledProcessError):
        pvlib.polytime(basepath=no_repo)
    d = pvlib.polytime(no_raise=True, basepath=no_repo)
    assert d.startswith(today)
def test_polyversion_BAD_custom_env_var(no_repo, empty_repo, untagged_repo,
                                        monkeypatch):
    monkeypatch.setenv('PPP', '1.2.3')
    root = (no_repo / '/')

    for repo in [no_repo, empty_repo, untagged_repo]:
        root.chdir()
        assert pvlib.polyversion(pname='foo',
                                 basepath=repo,
                                 default_version_env_var='PPP') == '1.2.3'
        pvlib.polytime(pname='foo',
                       basepath=repo,
                       default_version_env_var='PPP')
        pvlib.polytime(basepath=repo, default_version_env_var='PPP')

        repo.chdir()
        assert pvlib.polyversion(pname='foo',
                                 default_version_env_var='PPP') == '1.2.3'
        pvlib.polytime(pname='foo',
                       basepath=repo,
                       default_version_env_var='PPP')
        pvlib.polytime(basepath=repo, default_version_env_var='PPP')
def test_polytime_BAD_no_commits(empty_repo):
    with pytest.raises(sbp.CalledProcessError):
        pvlib.polytime(basepath=empty_repo)
def test_polytime_p2(ok_repo, today):
    d = pvlib.polytime(basepath=ok_repo)
    assert d.startswith(today)