def test_run_field_rules2(): config = { "rules": { "field_level_rules": [ { "name": "DescriptionRule", "run": True }, { "name": "YesNoNameRule", "run": True }, ] }, } linter = LookMlLinter(config) raw_lookml = """ view: engagement_score { } """ json_data = get_json_from_lookml(raw_lookml) v = json_data["views"][0] out = linter.run_field_rules(v, "dimension", "dimensions", "xxx", []) assert out == []
def test_process_file(): config = { "rules": { "other_rules": [{ "name": "NoOrphansRule", "run": True }] } } raw_lookml = """ view: aview { dimension: dimname { type: string } } """ filename = "test/aview.view.lkml" json_data = get_json_from_lookml(raw_lookml, filename) rule = NoOrphansRule(config) rule.process_file(json_data) d = rule.view_dict assert len(d) == 1 assert 'aview' in d assert d['aview'] == filename if os.path.exists(filename): os.remove(filename)
def test_run1(): raw_lookml = """ view: aview { sql_table_name: bqdw.engagement_score ;; } """ json_data = get_json_from_lookml(raw_lookml) relevant, passed = DataSourceRule().run(json_data) assert relevant assert passed
def test_run2(): raw_lookml = """ view: aview { dimension: memberID { type: string } } """ json_data = get_json_from_lookml(raw_lookml) relevant, passed = DataSourceRule().run(json_data) assert relevant assert not passed
def test_run3(): raw_lookml = """ connection: "datawarehouse" include: "*.view.lkml" explore: an_explore { } """ filename = "test/amodel.model.lkml" json_data = get_json_from_lookml(raw_lookml, filename) relevant, passed = OneViewPerFileRule().run(json_data) assert not relevant assert not passed if os.path.exists(filename): os.remove(filename)
def test_run(): raw_lookml = """ view: aview { dimension: memberID { type: string } } """ filename = "test/junkyname.view.lkml" json_data = get_json_from_lookml(raw_lookml,filename) relevant, passed = FilenameViewnameMatchRule().run(json_data) assert relevant assert not passed if os.path.exists(filename): os.remove(filename)
def test_run3(): raw_lookml = """ view: aview { derived_table: { sql: SELECT * from table ;; } dimension: memberID { type: string } } """ json_data = get_json_from_lookml(raw_lookml) relevant, passed = DataSourceRule().run(json_data) assert relevant assert passed
def test_run(): raw_lookml = """ view: first_view { dimension: memberID { type: string } } view: second_view { dimension: memberID { type: string } } """ json_data = get_json_from_lookml(raw_lookml) relevant, passed = OneViewPerFileRule().run(json_data) assert relevant assert not passed