예제 #1
0
def test_post_issues_connection_error(mock_session):
    with pytest.raises(requests.HTTPError):
        with env(GITHUB_USER="******"),\
            env(GHIA_CONFIG=(f'{make_path("auth.secret.cfg")}:'
                             f'{make_path("rules.fallback.cfg")}:'
                             f'{make_path("rules.no_fallback.cfg")}')):
            config = read_config()
            session = requests.Session()
            process_post_issues(load_example("issues_example.json"), config,
                                session)
예제 #2
0
def test_process_post_issues(mock_session):
    with env(GITHUB_USER="******"),\
         env(GHIA_CONFIG=(f'{make_path("auth.secret.cfg")}:'
                          f'{make_path("rules.fallback.cfg")}:'
                          f'{make_path("rules.no_fallback.cfg")}')):
        config = read_config()
    session = requests.Session()
    response = process_post_issues(load_example("issues_example.json"), config,
                                   session)
    assert "was successfully updated" in response
예제 #3
0
def test_read_config():
    with env(GITHUB_USER="******"),\
         env(GHIA_CONFIG=(f'{make_path("auth.secret.cfg")}:'
                          f'{make_path("rules.fallback.cfg")}:'
                          f'{make_path("rules.no_fallback.cfg")}')):
        d = read_config()
    assert "fallback" in d["rules"].keys()
    assert d["auth"]["user"] == "user"
    assert d["auth"]["token"] == "ffffffffffffffffffffffffffffffffffffffff"
    assert d["auth"]["secret"] == "tajneheslo"
    assert re.match(d["rules"]["ghia-anna"]["text"][0], "requests library")
    assert len(d["rules"]["ghia-jane"]["text"]) == 3
예제 #4
0
def test_config_errors(file1, file2):
    with pytest.raises(GhiaError) as e:
        with env(GITHUB_USER="******"),\
             env(GHIA_CONFIG=f"{make_path(file1)}:{make_path(file2)}"):
            read_config()
    assert "Invalid format of configuration file" in str(e.value)
예제 #5
0
def test_no_config_error():
    with pytest.raises(GhiaError) as e:
        with env(GITHUB_USER="******", GHIA_CONFIG=""):
            read_config()
    assert "Invalid format of configuration file" in str(e.value)
예제 #6
0
def test_user_error():
    with pytest.raises(GhiaError) as e:
        with env(GITHUB_USER=""):
            read_config()
    assert str(e.value) == "No GitHub user specified"