Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Re-enable test asserting calling metric nodes in models
  • Loading branch information
QMalcolm committed Jul 12, 2023
commit 2caf63d13f6ac56ec9f814e172d31c2cf8b3e161
32 changes: 30 additions & 2 deletions tests/functional/metrics/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,7 @@
label: {{ m.label }}
type: {{ m.type }}
type_params: {{ m.type_params }}
filters {{ m.filter }}
window: {{ m.window }}
filter: {{ m.filter }}
{% endfor %}

{% endif %}
Expand Down Expand Up @@ -376,6 +375,35 @@
- payment_type
"""

purchasing_model_sql = """
select purchased_at, payment_type, payment_total from {{ ref('mock_purchase_data') }}
"""

semantic_model_purchasing_yml = """
version: 2

semantic_models:
- name: semantic_purchasing
model: ref('purchasing')
measures:
- name: num_orders
agg: COUNT
expr: purchased_at
- name: order_revenue
agg: SUM
expr: payment_total
dimensions:
- name: purchased_at
type: TIME
entities:
- name: purchase
type: primary
expr: '1'
defaults:
agg_time_dimension: purchased_at

"""

derived_metric_yml = """
version: 2
metrics:
Expand Down
10 changes: 6 additions & 4 deletions tests/functional/metrics/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
invalid_metric_without_timestamp_with_window_yml,
metricflow_time_spine_sql,
semantic_model_people_yml,
semantic_model_purchasing_yml,
purchasing_model_sql,
)


Expand Down Expand Up @@ -232,8 +234,11 @@ class TestDerivedMetric:
@pytest.fixture(scope="class")
def models(self):
return {
"derived_metric.yml": derived_metric_yml,
"downstream_model.sql": downstream_model_sql,
"purchasing.sql": purchasing_model_sql,
"metricflow_time_spine.sql": metricflow_time_spine_sql,
"semantic_models.yml": semantic_model_purchasing_yml,
"derived_metric.yml": derived_metric_yml,
}

# not strictly necessary to use "real" mock data for this test
Expand All @@ -245,7 +250,6 @@ def seeds(self):
"mock_purchase_data.csv": mock_purchase_data_csv,
}

@pytest.mark.skip("TODO bring back once we start populating metric `depends_on`")
def test_derived_metric(
self,
project,
Expand Down Expand Up @@ -276,7 +280,6 @@ def test_derived_metric(

# make sure the 'expression' metric depends on the two upstream metrics
derived_metric = manifest.metrics["metric.test.average_order_value"]
assert sorted(derived_metric.metrics) == [["count_orders"], ["sum_order_revenue"]]
assert sorted(derived_metric.depends_on.nodes) == [
"metric.test.count_orders",
"metric.test.sum_order_revenue",
Expand All @@ -295,7 +298,6 @@ def test_derived_metric(
"type",
"type_params",
"filter",
"window",
]:
expected_value = getattr(parsed_metric_node, property)
assert f"{property}: {expected_value}" in compiled_code
Expand Down