def test_apply_splits_nodes_using_callable(empty_raw_manifest): passes = [Node({"original_file_path": "filepath1"})] failures = [ Node({"original_file_path": "filepath2"}), Node({"original_file_path": "filepath3"}), ] dummy_manifest = Manifest(empty_raw_manifest) rule = Rule("warning", "basic_rule", lambda _: (passes, failures)) result = rule.apply(dummy_manifest) assert result[0] == passes assert result[1] == failures
def test_should_convert_to_html_output(): rule: Rule = Rule("a-failed-rule", "a rule name", None) model1 = Node({"unique_id": "model1"}) model2 = Node({"unique_id": "model2"}) passes: List[Node] = [model1] failures: List[Node] = [model2] domain_results: List[Result] = [Result(rule, passes, failures)] metric_results: List[MetricResult] = [ MetricResult(model1, 0, 0, 0, 0, 0, 0), MetricResult(model2, 0, 0, 0, 0, 0, 0), ] actual: Report = to_html_report(domain_results, metric_results) assert actual == expected_html_report
def test_node_is_staging_when_in_fqn(): node = Node({ "unique_id": "staging.a", "fqn": ["staging", "a"], "resource_type": "model" }) assert node.is_staging
def test_node_is_mart_when_in_fqn(): node = Node({ "unique_id": "marts.a", "fqn": ["marts", "a"], "resource_type": "model" }) assert node.is_mart
def test_node_is_staging_when_prefixed_with_stg(): node = Node({ "unique_id": "stg_a", "fqn": ["stg_a"], "resource_type": "model" }) assert node.is_staging
def test_rule_engine_returns_results_for_rule_set(empty_raw_manifest): failures = [Node({})] engine = RuleEngine( [Rule("this always fails!", "test", lambda m: ([], failures))]) results = engine.run(Manifest(empty_raw_manifest)) assert len(results) == 1 assert isinstance(results[0], Result)
def test_rule_engine_extend(): nodes = [Node({})] engine_1 = RuleEngine( [Rule("test-1", "this always fails!", lambda m: ([], nodes))]) engine_2 = RuleEngine( [Rule("test-2", "this always succeeds!", lambda m: (nodes, []))]) engine_1.extend(engine_2) assert len(engine_1) == 2 assert ["test-1", "test-2"] == [r.id for r in engine_1]
def test_node_is_source(): node = Node({"unique_id": "a", "fqn": ["a"], "resource_type": "source"}) assert node.is_source