Example #1
0
def test_ruleset_additional_tags():
    tags = ["a"]
    r = {"version": "1", "checks": [{"name": "name_label", "additional_tags": tags[:]}]}
    r = Ruleset(ruleset=r)
    checks = r.get_checks(None)
    assert len(checks) == 1
    assert list(set(tags).intersection(set(checks[0].tags))) == tags
Example #2
0
def test_ruleset_tags():
    tags = ["a", "banana"]
    r = {"version": "1", "checks": [{"name": "name_label", "tags": tags[:]}]}
    r = Ruleset(ruleset=r)
    checks = r.get_checks(None)
    assert len(checks) == 1
    assert checks[0].tags == tags
Example #3
0
def test_ruleset_json():
    tests_dir = os.path.dirname(os.path.dirname(__file__))
    lol_ruleset_path = os.path.join(tests_dir, "data", "lol-ruleset.json")
    with open(lol_ruleset_path, "r") as fd:
        r = Ruleset(ruleset_file=fd)
        checks = r.get_checks(None)
    assert len(checks) == 1
Example #4
0
def test_ruleset_tags_filtering(tags, expected_check_name):
    r = {"version": "1", "checks": [{"name": "name_label"}]}
    r = Ruleset(ruleset=r)
    checks = r.get_checks(None, tags=tags)
    if expected_check_name:
        assert len(checks) == 1
        assert checks[0].name == expected_check_name
    else:
        assert len(checks) == 0
Example #5
0
def test_ruleset_version(version, should_raise):
    if version == "<blank>":
        r = {"banana": 123}
    else:
        r = {"version": version}
    if should_raise:
        with pytest.raises(ColinRulesetException):
            Ruleset(ruleset=r)
    else:
        assert Ruleset(ruleset=r)
Example #6
0
def test_ruleset_override():
    m = "my-message!"
    r = {
        "version": "1",
        "checks": [
            {"name": "name_label", "tags": ["a", "b"], "just": "testing", "message": m}
        ],
    }
    r = Ruleset(ruleset=r)
    checks = r.get_checks(None)
    assert len(checks) == 1
    assert checks[0].message == m
    assert checks[0].just == "testing"