Beispiel #1
0
import json
import sys

from dbrlint.dbrlinter import DBRLinter

if __name__ == "__main__":
    job_path = sys.argv[1]
    rules_path = sys.argv[2]

    with open(job_path, 'r') as fp:
        job_definition = json.load(fp)

    linter = DBRLinter(rules_path)

    errors = linter.evaluate(job_definition)

    if len(errors) > 0:
        print("Validation Failed:")
        for err in errors:
            print(err)
        sys.exit(1)
    else:
        print("Completed Successfully!  No errors in job definition.")
        sys.exit(0)
Beispiel #2
0
def test_parsing_rules_contains_no_quotes_middle():
    rules_string = "field2: [1,*,2]".split('\n')
    lint = DBRLinter(rules_string)

    assert (lint.rules[0] == ContainsMatch("field2", [1, 2]))
Beispiel #3
0
def test_parsing_rules_contains():
    rules_string = "field2: [1,2,\"*\"]".split('\n')
    lint = DBRLinter(rules_string)

    assert (lint.rules[0] == ContainsMatch("field2", [1, 2]))
Beispiel #4
0
def test_parsing_rules_exact():
    rules_string = "field1: sometext\nfield2: [1,2]".split('\n')
    lint = DBRLinter(rules_string)

    assert (lint.rules[0] == ExactMatch("field1", "sometext"))
    assert (lint.rules[1] == ExactMatch("field2", [1, 2]))
Beispiel #5
0
def test_parsing_rules_input_required_no_quotes():
    rules_string = "field2: [?]\nfield3: ?".split('\n')
    lint = DBRLinter(rules_string)

    assert (lint.rules[0] == InputRequired("field2", []))
    assert (lint.rules[1] == InputRequired("field3", "?"))