Пример #1
0
def test_run_file_rules():
    config = {
        "rules": {
            "file_level_rules": [
                {
                    "name": "DataSourceRule",
                    "run": True
                },
                {
                    "name": "OneViewPerFileRule",
                    "run": False
                },
                {
                    "name": "FilenameViewnameMatchRule",
                    "run": True
                },
            ]
        },
    }
    linter = LookMlLinter(config)

    rule = DataSourceRule()
    lookml = LookML("test/minimal_multiline.view.lkml")
    out = linter.run_file_rules(lookml, "xxx", [])
    assert len(out) == 2
    assert out[0] == {"file": "xxx", "passed": 1, "rule": "DataSourceRule"}
    assert out[1] == {
        "file": "xxx",
        "passed": 0,
        "rule": "FilenameViewnameMatchRule"
    }
Пример #2
0
def test_run_file_rules():
    config = {
        "parser": "lookml-parser",
        "tmp_file": "parsed_lookml.json",
        "rules": {
            "file_level_rules": [{
                "name": "DataSourceRule",
                "run": True
            }, {
                "name": "OneViewPerFileRule",
                "run": False
            }, {
                "name": "FilenameViewnameMatchRule",
                "run": True
            }]
        },
    }
    linter = LookMlLinter(config)

    rule = DataSourceRule()
    json_data = LookML(config).get_json_representation(
        "test/minimal_multiline.lkml")
    out = linter.run_file_rules(json_data, "xxx", [])
    assert len(out) == 2
    assert out[0] == {'file': 'xxx', 'passed': 1, 'rule': 'DataSourceRule'}
    assert out[1] == {
        'file': 'xxx',
        'passed': 0,
        'rule': 'FilenameViewnameMatchRule'
    }
    if os.path.exists(config['tmp_file']):
        os.remove(config['tmp_file'])