-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add parser test for conversion metrics.
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
metricflow-semantics/tests_metricflow_semantics/query/test_conversion_metrics.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from __future__ import annotations | ||
|
||
import pytest | ||
from _pytest.fixtures import FixtureRequest | ||
from metricflow_semantics.model.semantic_manifest_lookup import SemanticManifestLookup | ||
from metricflow_semantics.query.query_parser import MetricFlowQueryParser | ||
from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration | ||
from metricflow_semantics.test_helpers.snapshot_helpers import assert_object_snapshot_equal | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def query_parser(simple_semantic_manifest) -> MetricFlowQueryParser: # noqa: D103 | ||
return MetricFlowQueryParser(SemanticManifestLookup(simple_semantic_manifest)) | ||
|
||
|
||
@pytest.mark.sql_engine_snapshot | ||
def test_conversion_rate_with_constant_properties( # noqa: D103 | ||
request: FixtureRequest, | ||
mf_test_configuration: MetricFlowTestConfiguration, | ||
query_parser: MetricFlowQueryParser, | ||
) -> None: | ||
result = query_parser.parse_and_validate_query( | ||
metric_names=("visit_buy_conversion_rate_by_session",), | ||
group_by_names=("visit__referrer_id", "user__home_state_latest", "metric_time"), | ||
) | ||
|
||
assert_object_snapshot_equal( | ||
request=request, | ||
mf_test_configuration=mf_test_configuration, | ||
obj=result, | ||
) |
24 changes: 24 additions & 0 deletions
24
...ion_metrics.py/ParseQueryResult/test_conversion_rate_with_constant_properties__result.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
ParseQueryResult( | ||
query_spec=MetricFlowQuerySpec( | ||
metric_specs=(MetricSpec(element_name='visit_buy_conversion_rate_by_session'),), | ||
dimension_specs=( | ||
DimensionSpec( | ||
element_name='referrer_id', | ||
entity_links=(EntityReference(element_name='visit'),), | ||
), | ||
DimensionSpec( | ||
element_name='home_state_latest', | ||
entity_links=(EntityReference(element_name='user'),), | ||
), | ||
), | ||
time_dimension_specs=(TimeDimensionSpec(element_name='metric_time', time_granularity=DAY),), | ||
filter_intersection=PydanticWhereFilterIntersection(), | ||
filter_spec_resolution_lookup=FilterSpecResolutionLookUp(), | ||
min_max_only=False, | ||
), | ||
queried_semantic_models=( | ||
SemanticModelReference(semantic_model_name='buys_source'), | ||
SemanticModelReference(semantic_model_name='users_latest'), | ||
SemanticModelReference(semantic_model_name='visits_source'), | ||
), | ||
) |