Skip to content

Commit

Permalink
Adjusted test to conform to pydantic change of validation behavior (n…
Browse files Browse the repository at this point in the history
…o more casting)
  • Loading branch information
esciara committed Nov 25, 2023
1 parent 77c7ebb commit d56449a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion dbt_semantic_interfaces/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def base_semantic_manifest_file() -> YamlConfigFile:
This is useful to seed a simple error-free semantic manifest, which can easily be extended with YAML inputs
containing specific validation triggers.
"""
# TODO: check if expr: 1 was intended to be expr: "1". If not, adjust code to handle both cases
yaml_contents = textwrap.dedent(
"""\
semantic_model:
Expand All @@ -92,7 +93,7 @@ def base_semantic_manifest_file() -> YamlConfigFile:
- name: num_sample_rows
agg: sum
agg_time_dimension: ds
expr: 1
expr: "1"
create_metric: true
dimensions:
- name: ds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ semantic_model:

measures:
- name: listings
expr: 1
expr: "1"
agg: sum
- name: largest_listing
expr: capacity
Expand Down
12 changes: 8 additions & 4 deletions tests/validations/test_measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def test_metric_missing_measure() -> None:


def test_measures_only_exist_in_one_semantic_model() -> None: # noqa: D
# TODO: check if expr: 1 was intended to be expr: "1". If not, adjust code to handle both cases
yaml_contents_1 = textwrap.dedent(
"""\
semantic_model:
Expand All @@ -80,7 +81,7 @@ def test_measures_only_exist_in_one_semantic_model() -> None: # noqa: D
measures:
- name: num_sample_rows
agg: sum
expr: 1
expr: "1"
create_metric: true
dimensions:
- name: ds
Expand All @@ -106,6 +107,7 @@ def test_measures_only_exist_in_one_semantic_model() -> None: # noqa: D

assert found_issue is False

# TODO: check if expr: 1 was intended to be expr: "1". If not, adjust code to handle both cases
yaml_contents_2 = textwrap.dedent(
"""\
semantic_model:
Expand All @@ -121,7 +123,7 @@ def test_measures_only_exist_in_one_semantic_model() -> None: # noqa: D
measures:
- name: num_sample_rows
agg: sum
expr: 1
expr: "1"
create_metric: true
dimensions:
- name: ds
Expand Down Expand Up @@ -233,6 +235,7 @@ def test_invalid_non_additive_dimension_properties() -> None:

def test_count_measure_missing_expr() -> None:
"""Tests that all measures with COUNT agg should have expr provided."""
# TODO: check if expr: 1 was intended to be expr: "1". If not, adjust code to handle both cases
yaml_contents = textwrap.dedent(
"""\
semantic_model:
Expand All @@ -248,7 +251,7 @@ def test_count_measure_missing_expr() -> None:
measures:
- name: num_sample_rows
agg: sum
expr: 1
expr: "1"
create_metric: true
- name: bad_measure
agg: count
Expand Down Expand Up @@ -286,6 +289,7 @@ def test_count_measure_missing_expr() -> None:

def test_count_measure_with_distinct_expr() -> None:
"""Tests that measures with COUNT agg can NOT use the DISTINCT keyword."""
# TODO: check if expr: 1 was intended to be expr: "1". If not, adjust code to handle both cases
yaml_contents = textwrap.dedent(
"""\
semantic_model:
Expand All @@ -301,7 +305,7 @@ def test_count_measure_with_distinct_expr() -> None:
measures:
- name: num_sample_rows
agg: sum
expr: 1
expr: "1"
create_metric: true
- name: distinct_count
agg: count
Expand Down

0 comments on commit d56449a

Please sign in to comment.