From 2be14595c5afc821893c18489a37d41caf1b3b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Far=C3=ADas=20Santana?= Date: Tue, 28 Jan 2025 11:21:50 +0100 Subject: [PATCH] fix: Fix some tests and mypy lints --- posthog/api/test/batch_exports/test_create.py | 2 +- posthog/api/test/batch_exports/test_update.py | 1 + posthog/temporal/batch_exports/spmc.py | 7 +++++-- posthog/temporal/tests/batch_exports/test_spmc.py | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/posthog/api/test/batch_exports/test_create.py b/posthog/api/test/batch_exports/test_create.py index 7f46d0d7447593..bd15c9ca72bc14 100644 --- a/posthog/api/test/batch_exports/test_create.py +++ b/posthog/api/test/batch_exports/test_create.py @@ -348,7 +348,7 @@ def test_create_batch_export_with_custom_schema(client: HttpClient): } assert batch_export.schema == expected_schema - assert args["batch_export_model"] == {"name": "events", "schema": expected_schema} + assert args["batch_export_model"] == {"filters": None, "name": "events", "schema": expected_schema} @pytest.mark.parametrize( diff --git a/posthog/api/test/batch_exports/test_update.py b/posthog/api/test/batch_exports/test_update.py index 2db2d1af5cf04f..641e2fc9dca7c0 100644 --- a/posthog/api/test/batch_exports/test_update.py +++ b/posthog/api/test/batch_exports/test_update.py @@ -322,6 +322,7 @@ def test_can_patch_hogql_query(client: HttpClient): assert args["interval"] == "hour" assert args["batch_export_model"] == { "name": "events", + "filters": None, "schema": { "fields": [ { diff --git a/posthog/temporal/batch_exports/spmc.py b/posthog/temporal/batch_exports/spmc.py index a53ee5a05f649e..972e7339ccc13c 100644 --- a/posthog/temporal/batch_exports/spmc.py +++ b/posthog/temporal/batch_exports/spmc.py @@ -858,7 +858,7 @@ def compose_filters_clause( ) context.database = create_hogql_database(team.id, context.modifiers) - exprs = [property_to_expr(EventPropertyFilter(**filter), team=team) for filter in filters] # type: ignore + exprs = [property_to_expr(EventPropertyFilter(**filter), team=team) for filter in filters] and_expr = ast.And(exprs=exprs) select_query = ast.SelectQuery( select=[parse_expr("properties as properties")], @@ -873,7 +873,10 @@ def compose_filters_clause( ) printed = print_prepared_ast( - prepared_and_expr, context=context, dialect="clickhouse", stack=[prepared_select_query] + prepared_and_expr, # type: ignore + context=context, + dialect="clickhouse", + stack=[prepared_select_query], ) return printed, context.values diff --git a/posthog/temporal/tests/batch_exports/test_spmc.py b/posthog/temporal/tests/batch_exports/test_spmc.py index 91b69d4192e382..62d61d6f423064 100644 --- a/posthog/temporal/tests/batch_exports/test_spmc.py +++ b/posthog/temporal/tests/batch_exports/test_spmc.py @@ -240,9 +240,9 @@ def test_use_events_recent(test_data: dict[str, typing.Any]): ), ], ) -async def test_compose_filters_clause( +def test_compose_filters_clause( filters: list[dict[str, typing.Any]], expected_clause: str, expected_values: dict[str, str], ateam ): - result_clause, result_values = await compose_filters_clause(filters, team_id=ateam.id) + result_clause, result_values = compose_filters_clause(filters, team_id=ateam.id) assert result_clause == expected_clause assert result_values == expected_values