Skip to content

Commit

Permalink
Adding test to verify row counts.
Browse files Browse the repository at this point in the history
  • Loading branch information
phixMe committed Feb 25, 2025
1 parent a53466f commit 025c593
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions posthog/temporal/tests/data_modeling/test_run_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ async def test_run_dag_activity_activity_materialize_mocked(activity_environment

calls = magic_mock.mock_calls

assert all(
call.args[0] in models_materialized for call in calls
), f"Found models that shouldn't have been materialized: {tuple(call.args[0] for call in calls if call.args[0] not in models_materialized)}"
assert all(
call.args[1].pk == ateam.pk for call in calls
), f"Found team ids that do not match test team ({ateam.pk}): {tuple(call.args[1].pk for call in calls)}"
assert all(call.args[0] in models_materialized for call in calls), (
f"Found models that shouldn't have been materialized: {tuple(call.args[0] for call in calls if call.args[0] not in models_materialized)}"
)
assert all(call.args[1].pk == ateam.pk for call in calls), (
f"Found team ids that do not match test team ({ateam.pk}): {tuple(call.args[1].pk for call in calls)}"
)
assert len(calls) == len(models_materialized)
assert results.completed == set(dag.keys())

Expand Down Expand Up @@ -205,12 +205,12 @@ def raise_if_should_make_fail(model_label, *args, **kwargs):

calls = magic_mock.mock_calls

assert all(
call.args[0] in models_materialized for call in calls
), f"Found models that shouldn't have been materialized: {tuple(call.args[0] for call in calls if call.args[0] not in models_materialized)}"
assert all(
call.args[1].pk == ateam.pk for call in calls
), f"Found team ids that do not match test team ({ateam.pk}): {tuple(call.args[1].pk for call in calls)}"
assert all(call.args[0] in models_materialized for call in calls), (
f"Found models that shouldn't have been materialized: {tuple(call.args[0] for call in calls if call.args[0] not in models_materialized)}"
)
assert all(call.args[1].pk == ateam.pk for call in calls), (
f"Found team ids that do not match test team ({ateam.pk}): {tuple(call.args[1].pk for call in calls)}"
)
assert len(calls) == len(models_materialized)

assert results.completed == expected_completed
Expand Down Expand Up @@ -678,3 +678,10 @@ async def test_run_workflow_with_minio_bucket(
assert sorted(table.to_pylist(), key=lambda d: (d["distinct_id"], d["timestamp"])) == expected_data
assert query.status == DataWarehouseSavedQuery.Status.COMPLETED
assert query.last_run_at == TEST_TIME

# Verify row count was updated in the DataWarehouseTable
warehouse_table = await database_sync_to_async(
DataWarehouseTable.objects.filter(team_id=ateam.pk, name=query.name).first
)()
assert warehouse_table is not None, f"DataWarehouseTable for {query.name} not found"
assert warehouse_table.row_count == len(expected_data), f"Row count for {query.name} not the expected value"

0 comments on commit 025c593

Please sign in to comment.