def test_single_issue_error(prepare_session, capsys): rules = validate_rules(None, None, make_path("rules.valid.cfg")) process_repository("ghia-anna/awesome", "append", prepare_session, rules, False) out, err = capsys.readouterr() assert "-> ghia-anna/awesome#1 (https://github.com/ghia-anna/awesome/issues/1)" in out assert " ERROR: Could not update issue ghia-anna/awesome#1" in err
def test_reading_issues_error(prepare_session): rules = validate_rules(None, None, make_path("rules.empty.cfg")) with pytest.raises(GhiaError) as e: process_repository("mi-pyt-ghia/kotlalu", "append", prepare_session, rules, False) assert str( e.value) == "Could not list issues for repository mi-pyt-ghia/kotlalu"
def test_apply_rules(prepare_session, capsys): rules = validate_rules(None, None, make_path("rules.valid.cfg")) process_repository("mi-pyt-ghia/kotlaluk", "append", prepare_session, rules, False) out, err = capsys.readouterr() assert len(err) == 0 assert '-> mi-pyt-ghia/kotlaluk#5 (https://github.com/mi-pyt-ghia/kotlaluk/issues/5)\n' \ ' = ghia-anna\n' in out assert '-> mi-pyt-ghia/kotlaluk#7 (https://github.com/mi-pyt-ghia/kotlaluk/issues/7)\n' \ ' = ghia-anna\n' \ ' = ghia-john\n' \ ' + ghia-peter\n' in out assert '-> mi-pyt-ghia/kotlaluk#8 (https://github.com/mi-pyt-ghia/kotlaluk/issues/8)\n' \ ' = ghia-anna\n' \ ' = ghia-peter\n' in out assert '-> mi-pyt-ghia/kotlaluk#24 (https://github.com/mi-pyt-ghia/kotlaluk/issues/24)\n' \ ' = ghia-anna\n' in out assert '-> mi-pyt-ghia/kotlaluk#27 (https://github.com/mi-pyt-ghia/kotlaluk/issues/27)\n' \ ' + ghia-peter\n' in out assert '-> mi-pyt-ghia/kotlaluk#117 (https://github.com/mi-pyt-ghia/kotlaluk/issues/117)\n' \ ' = ghia-anna\n' in out assert '-> mi-pyt-ghia/kotlaluk#118 (https://github.com/mi-pyt-ghia/kotlaluk/issues/118)\n' \ ' = ghia-peter\n' in out assert ' FALLBACK:' in out
def test_reading_issues(prepare_session, capsys): """Tests that all issue pages are read""" rules = validate_rules(None, None, make_path("rules.empty.cfg")) process_repository("mi-pyt-ghia/kotlaluk", "append", prepare_session, rules, False) out, err = capsys.readouterr() assert len(err) == 0 assert "-> mi-pyt-ghia/kotlaluk#1 (https://github.com/mi-pyt-ghia/kotlaluk/issues/1)" in out assert "-> mi-pyt-ghia/kotlaluk#120 (https://github.com/mi-pyt-ghia/kotlaluk/issues/120)" in out
def test_invalid_rules(file): with pytest.raises(BadParameter) as e: validate_rules(ctx, param, make_path(file)) assert str(e.value) == "incorrect configuration format"
def test_rules_with_fallback(): d = validate_rules(ctx, param, make_path("rules.fallback.cfg")) assert d["fallback"] == "Need assignment" assert len(d) == 1
def test_rules_valid(): d = validate_rules(ctx, param, make_path("rules.valid.cfg")) assert "fallback" in d.keys() assert "title" in d["ghia-anna"].keys() assert re.match(d["ghia-john"]["label"][0], "assign-john") assert len(d["ghia-peter"]["any"]) == 2
def test_rules_empty(): d = validate_rules(ctx, param, make_path("rules.empty.cfg")) assert type(d) == dict assert len(d) == 0
def test_reset_rules(prepare_session, capsys): rules = validate_rules(None, None, make_path("rules.reset.cfg")) process_repository("mi-pyt-ghia/kotlaluk", "change", prepare_session, rules, False) out, err = capsys.readouterr() assert len(err) == 0