Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the default custom package name to custom for disambiguation #2

Merged
merged 1 commit into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/application-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ jobs:
- name: ✅ Run unit tests
run: poetry run pytest
env:
# TODO: The tests should configure this themselves
DBT_PY_PACKAGE_ROOT: "tests.integration.jaffle-shop.dbt_py"
DBT_PY_PACKAGE_NAME: "dbt_py"
# TODO: This is configured in the tests, but not being picked up in CI
DBT_PY_PACKAGE_ROOT: "tests.integration.jaffle-shop.dbt_py_test"
DBT_PY_PACKAGE_NAME: "dbt_py_test"
2 changes: 1 addition & 1 deletion dbt_py/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
from dbt_py.main import PROJECT_ROOT, main

__all__ = [
"main",
"PROJECT_ROOT",
"main",
]
5 changes: 3 additions & 2 deletions dbt_py/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@

PROJECT_ROOT = pathlib.Path(__file__).parent.parent
# Python-style ref, e.g. `package.module.submodule`
PACKAGE_ROOT: str = os.environ.get("DBT_PY_PACKAGE_ROOT", "dbt_py")
PACKAGE_ROOT: str = os.environ.get("DBT_PY_PACKAGE_ROOT", "custom")
# The name to associate with the package
PACKAGE_NAME: str = os.environ.get("DBT_PY_PACKAGE_NAME", PACKAGE_ROOT)


def import_submodules(
package_name: str, recursive: bool = True
package_name: str,
recursive: bool = True,
) -> dict[str, ModuleType]:
"""
Import all submodules of a module, recursively, including subpackages.
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/jaffle-shop/dbt-commands.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Just for reference
# $env:DBT_PY_PACKAGE_ROOT = "tests.integration.jaffle-shop.dbt_py"
# $env:DBT_PY_PACKAGE_NAME = "dbt_py"
# $env:DBT_PY_PACKAGE_ROOT = "tests.integration.jaffle-shop.dbt_py_test"
# $env:DBT_PY_PACKAGE_NAME = "dbt_py_test"
dbt clean --project-dir tests/integration/jaffle-shop --profiles-dir tests/integration/jaffle-shop --no-clean-project-files-only
dbt-py compile --project-dir tests/integration/jaffle-shop --profiles-dir tests/integration/jaffle-shop
rm dbt_packages
8 changes: 4 additions & 4 deletions tests/integration/jaffle-shop/models/example.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ modules.dbt_py.some_module.select_final() }}
{{ modules.dbt_py.some_module.salutation("World") }}
{{ modules.dbt_py_test.some_module.select_final() }}
{{ modules.dbt_py_test.some_module.salutation("World") }}

{{ modules.dbt_py.select_final() }}
{{ modules.dbt_py.salutation("World") }}
{{ modules.dbt_py_test.select_final() }}
{{ modules.dbt_py_test.salutation("World") }}
17 changes: 12 additions & 5 deletions tests/integration/test__integration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Integration tests for the package.
"""
import os
import textwrap
import unittest.mock

Expand Down Expand Up @@ -30,13 +29,21 @@
)


def test__integration() -> None:
@pytest.fixture
def mock_env(monkeypatch) -> None:
"""
Placeholder integration test.
Mock the environment variables used by dbt_py.
"""
os.environ["DBT_PY_PACKAGE_ROOT"] = "tests.integration.jaffle-shop.dbt_py"
os.environ["DBT_PY_PACKAGE_NAME"] = "dbt_py"
monkeypatch.setenv(
"DBT_PY_PACKAGE_ROOT", "tests.integration.jaffle-shop.dbt_py_test"
)
monkeypatch.setenv("DBT_PY_PACKAGE_NAME", "dbt_py_test")


def test__integration(mock_env) -> None:
"""
Placeholder integration test.
"""
with unittest.mock.patch("sys.argv", ["", "compile", *ARGS]):
dbt_py.main()

Expand Down