visch
10/29/2021, 3:04 PMvisch
10/29/2021, 3:08 PMpytest
2. Spin up local container with Postgres
3. meltano elt tap-name target-postgres --transform dbt:test
(wrong command for dbt I"m sure)
4. Profit?
Anyone done this / have pointers? Big thing for me is making sure the code is testable without needing a server setup before handstephen_bailey
10/29/2021, 3:08 PMvisch
10/29/2021, 3:09 PMstephen_bailey
10/29/2021, 3:09 PMvisch
10/29/2021, 3:09 PMmeltano elt tap-name target-postgres --transform dbt:test
work? I could just run meltano dbt:test
as wellstephen_bailey
10/29/2021, 3:10 PMstephen_bailey
10/29/2021, 3:10 PMvisch
10/29/2021, 3:11 PMstephen_bailey
10/29/2021, 3:11 PMvisch
10/29/2021, 3:12 PMtarget-*
, and dbt
stephen_bailey
10/29/2021, 3:13 PMth.Property("updated_at", th.DateTimeType, expectations=["is_valid_timestamp", "not_null"])
and then run pytest
and it runs the not_null
and is_valid_timestamp
testsvisch
10/29/2021, 3:14 PM"select (*) from tasks where archived = 'true'
count should be >= 1stephen_bailey
10/29/2021, 3:15 PMvisch
10/29/2021, 3:15 PMvisch
10/29/2021, 3:15 PMdbt
or not as a part of the test run with the tapstephen_bailey
10/29/2021, 3:16 PMdef test_archived_tasks_greater_than_zero(test_util):
records = self.records["tasks"]
assert len(r for r in records if r["archived"]) > 0
taylor
10/29/2021, 7:18 PMtaylor
10/29/2021, 7:18 PMtaylor
10/29/2021, 7:18 PMvisch
10/29/2021, 7:19 PMtaylor
10/29/2021, 7:20 PMvisch
10/29/2021, 7:21 PMvisch
10/29/2021, 7:23 PMpodman run -e POSTGRES_PASSWORD=postgres -p 5432:5432 -h postgres -d postgres
🤷taylor
10/29/2021, 7:23 PMtaylor
10/29/2021, 7:23 PMvisch
10/29/2021, 7:23 PMvisch
10/29/2021, 7:23 PMtaylor
10/29/2021, 7:23 PMvisch
10/29/2021, 7:23 PMvisch
10/29/2021, 7:24 PMstephen_bailey
11/01/2021, 6:28 PMtest_manifest
array and a pytest.mark.parameterize
decorator.
the test_manifest is a list of test_name
and `params`:
TEST_MANIFEST = [
("tap__cli", {}),
("tap__discovery", {}),
("tap__stream_connections", {}),
("stream__catalog_schema_matches_record", {"stream_name": "channels"}),
("stream__record_schema_matches_catalog", {"stream_name": "channels"}),
...
("stream__returns_record", {"stream_name": "users"}),
("stream__primary_key", {"stream_name": "users"}),
("attribute__unique", {"stream_name": "channels", "attribute_name": "id"}),
("attribute__not_null", {"stream_name": "channels", "attribute_name": "id"}),
]
and then you parameterize a single function that pulls the test function from the test utility and runs it.
@pytest.mark.parametrize(
"test_config", TEST_MANIFEST
)
def test_builtin_tap_tests(test_util, test_config):
test_name, params = test_config
test_func = test_util.available_tests[test_name]
test_func(**params)
will carve out some time and demo it next week. it works surprisingly wellstephen_bailey
11/01/2021, 6:28 PMvisch
11/02/2021, 1:07 PMstephen_bailey
11/02/2021, 3:59 PM