Skip to content

Commit

Permalink
fixes linter and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolfix committed Jul 8, 2024
1 parent 308d232 commit 76728ba
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/website/docs/general-usage/naming-convention.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Snippet above demonstrates how to apply certain naming for an example `zendesk`
You can use naming conventions that you created yourself or got from other users. In that case you should pass a full Python import path to the [module that contain the naming convention](#write-your-own-naming-convention):
```toml
[schema]
"tests.common.cases.normalizers.sql_upper"
naming="tests.common.cases.normalizers.sql_upper"
```
`dlt` will import `tests.common.cases.normalizers.sql_upper` and use `NamingConvention` class found in it as the naming convention.

Expand Down
13 changes: 10 additions & 3 deletions tests/load/test_job_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ def client(request, naming) -> Iterator[SqlJobClientBase]:

@pytest.fixture(scope="function")
def naming(request) -> str:
os.environ["SCHEMA__NAMING"] = request.param
return request.param
# NOTE: this fixture is forced by `client` fixture which requires it goes first
# so sometimes there's no request available
if hasattr(request, "param"):
os.environ["SCHEMA__NAMING"] = request.param
return request.param
return None


@pytest.mark.order(1)
Expand Down Expand Up @@ -203,9 +207,12 @@ def test_complete_load(naming: str, client: SqlJobClientBase) -> None:
assert load_rows[0][4] == client.schema.version_hash
# make sure that hash in loads exists in schema versions table
versions_table = client.sql_client.make_qualified_table_name(version_table_name)
version_hash_column = client.sql_client.escape_column_name(
client.schema.naming.normalize_identifier("version_hash")
)
version_rows = list(
client.sql_client.execute_sql(
f"SELECT * FROM {versions_table} WHERE version_hash = %s", load_rows[0][4]
f"SELECT * FROM {versions_table} WHERE {version_hash_column} = %s", load_rows[0][4]
)
)
assert len(version_rows) == 1
Expand Down
8 changes: 6 additions & 2 deletions tests/load/test_sql_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ def client(request, naming) -> Iterator[SqlJobClientBase]:

@pytest.fixture(scope="function")
def naming(request) -> str:
os.environ["SCHEMA__NAMING"] = request.param
return request.param
# NOTE: this fixture is forced by `client` fixture which requires it goes first
# so sometimes there's no request available
if hasattr(request, "param"):
os.environ["SCHEMA__NAMING"] = request.param
return request.param
return None


@pytest.mark.parametrize(
Expand Down

0 comments on commit 76728ba

Please sign in to comment.