Skip to content

Commit

Permalink
Write integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Nov 8, 2023
1 parent 041309c commit eea8492
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
1 change: 1 addition & 0 deletions metricflow/test/integration/configured_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Config: # noqa: D
where_filter: Optional[str] = None
limit: Optional[int] = None
description: Optional[str] = None
min_max_only: bool = False


class TestCaseParseException(Exception):
Expand Down
58 changes: 56 additions & 2 deletions metricflow/test/integration/test_cases/itest_dimensions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ integration_test:
---
integration_test:
name: query_dimension_only
description: Query dimenension only
description: Query dimension only
model: SIMPLE_MODEL
group_bys: ["user__home_state"]
check_query: |
Expand Down Expand Up @@ -171,7 +171,7 @@ integration_test:
---
integration_test:
name: query_dimension_only_with_constraint
description: Query dimenension only
description: Query dimension only with a constraint
model: SIMPLE_MODEL
group_bys: ["user__home_state"]
where_filter: "{{ render_dimension_template('user__home_state') }} = 'CA'"
Expand All @@ -182,3 +182,57 @@ integration_test:
WHERE u.home_state = 'CA'
GROUP BY
u.home_state
---
integration_test:
name: min_max_only_categorical
description: Get min and max of a categorical dimension
model: SIMPLE_MODEL
group_bys: ["user__home_state"]
min_max_only: true
check_query: |
SELECT
MIN(user__home_state) AS min
, MAX(user__home_state) AS max
FROM (
SELECT
u.home_state AS user__home_state
FROM {{ source_schema }}.dim_users u
GROUP BY
u.home_state
)
---
integration_test:
name: min_max_only_time
description: Get min and max of a time dimension
model: SIMPLE_MODEL
group_bys: ["verification__ds"]
min_max_only: true
check_query: |
SELECT
MIN(verification__ds__day) AS min
, MAX(verification__ds__day) AS max
FROM (
SELECT
v.ds as verification__ds__day
FROM {{ source_schema }}.fct_id_verifications v
GROUP BY
v.ds
)
---
integration_test:
name: min_max_only_time_month
description: Get min and max of a time dimension with month granularity
model: SIMPLE_MODEL
group_bys: ["verification__ds__month"]
min_max_only: true
check_query: |
SELECT
MIN(verification__ds__month) AS min
, MAX(verification__ds__month) AS max
FROM (
SELECT
{{ render_date_trunc("v.ds", TimeGranularity.MONTH) }} as verification__ds__month
FROM {{ source_schema }}.fct_id_verifications v
GROUP BY
{{ render_date_trunc("v.ds", TimeGranularity.MONTH) }}
)

0 comments on commit eea8492

Please sign in to comment.