-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update repository unit tests to have
Project
fixture and do additio…
…nal `Project` testing (#10022) * Add `Project` fixture for unit tests and test `Project` class methods * Move `Project.__eq__` unit tests to new pytest class testing * Move `Project.hashed_name` unit test to pytest testing class * Rename some testing class in `test_project.py` to align with testing split * Refactor `project` fixture to make accessible to other unit tests
- Loading branch information
Showing
3 changed files
with
133 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import pytest | ||
|
||
import dbt.config | ||
import dbt.exceptions | ||
from dbt.adapters.contracts.connection import QueryComment | ||
from dbt.config.project import Project, RenderComponents, VarProvider | ||
from dbt.config.selectors import SelectorConfig | ||
from dbt.contracts.project import PackageConfig | ||
from dbt_common.semver import VersionSpecifier | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def selector_config() -> SelectorConfig: | ||
return SelectorConfig.selectors_from_dict( | ||
data={ | ||
"selectors": [ | ||
{ | ||
"name": "my_selector", | ||
"definition": "give me cats", | ||
"default": True, | ||
} | ||
] | ||
} | ||
) | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def project(selector_config: SelectorConfig) -> Project: | ||
return Project( | ||
project_name="test_project", | ||
version=1.0, | ||
project_root="doesnt/actually/exist", | ||
profile_name="test_profile", | ||
model_paths=["models"], | ||
macro_paths=["macros"], | ||
seed_paths=["seeds"], | ||
test_paths=["tests"], | ||
analysis_paths=["analyses"], | ||
docs_paths=["docs"], | ||
asset_paths=["assets"], | ||
target_path="target", | ||
snapshot_paths=["snapshots"], | ||
clean_targets=["target"], | ||
log_path="path/to/project/logs", | ||
packages_install_path="dbt_packages", | ||
packages_specified_path="packages.yml", | ||
quoting={"database": True, "schema": True, "identifier": True}, | ||
models={}, | ||
on_run_start=[], | ||
on_run_end=[], | ||
dispatch=[{"macro_namespace": "dbt_utils", "search_order": ["test_project", "dbt_utils"]}], | ||
seeds={}, | ||
snapshots={}, | ||
sources={}, | ||
data_tests={}, | ||
unit_tests={}, | ||
metrics={}, | ||
semantic_models={}, | ||
saved_queries={}, | ||
exposures={}, | ||
vars=VarProvider({}), | ||
dbt_version=[VersionSpecifier.from_version_string(dbt.version.__version__)], | ||
packages=PackageConfig([]), | ||
manifest_selectors={}, | ||
selectors=selector_config, | ||
query_comment=QueryComment(), | ||
config_version=1, | ||
unrendered=RenderComponents({}, {}, {}), | ||
project_env_vars={}, | ||
restrict_access=False, | ||
dbt_cloud={}, | ||
) |