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

create a happy path project fixture #10291

Merged
merged 6 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 0 additions & 1 deletion core/dbt/tests/fixtures/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@
project_root,
profiles_root,
profiles_yml,
dbt_project_yml,
clean_up_logging,
):
# The profiles.yml and dbt_project.yml should already be written out
Expand Down Expand Up @@ -602,4 +601,4 @@
project_files,
project_setup: TestProjInfo,
):
return project_setup

Check warning on line 604 in core/dbt/tests/fixtures/project.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/tests/fixtures/project.py#L604

Added line #L604 was not covered by tests
1 change: 0 additions & 1 deletion core/dbt/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def run_dbt(
args.extend(["--project-dir", project_dir])
if profiles_dir and "--profiles-dir" not in args:
args.extend(["--profiles-dir", profiles_dir])

dbt = dbtRunner()
res = dbt.invoke(args)

Expand Down
1 change: 1 addition & 0 deletions tests/functional/adapter/basic/test_adapter_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def project_files(
project_root,
tests,
models,
dbt_project_yml,
):
write_project_files(project_root, "tests", tests)
write_project_files(project_root, "models", models)
Expand Down
30 changes: 9 additions & 21 deletions tests/functional/list/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,6 @@ class TestList:
def dir(self, value):
return os.path.normpath(value)

# @pytest.fixture(scope="class")
# def project_config_update(self):
# return {
# "config-version": 2,
# "analysis-paths": [self.dir("analyses")],
# "snapshot-paths": [self.dir("snapshots")],
# "macro-paths": [self.dir("macros")],
# "seed-paths": [self.dir("seeds")],
# "test-paths": [self.dir("tests")],
# "seeds": {
# "quote_columns": False,
# },
# }

def test_packages_install_path_does_not_exist(self, happy_path_project): # noqa: F811
run_dbt(["list"])
packages_install_path = "dbt_packages"
Expand Down Expand Up @@ -56,7 +42,7 @@ def expect_given_output(self, args, expectations):
else:
assert got == expected

def expect_snapshot_output(self, project):
def expect_snapshot_output(self, happy_path_project): # noqa: F811
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this test we're actually using the happy_path_project fixture argument in the function. Is the # noqa: F811 necessary for another reason?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, also curious about this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for whatever reason flake8 was complaining about all of these in my local dev environment.
Let me try again and see what happened here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the problem with pytest, I don't see a easy way of getting rid of it.
https://stackoverflow.com/questions/50268284/why-im-getting-f811-error-in-this-code

expectations = {
"name": "my_snapshot",
"selector": "test.snapshot.my_snapshot",
Expand All @@ -75,8 +61,8 @@ def expect_snapshot_output(self, project):
"quoting": {},
"column_types": {},
"persist_docs": {},
"target_database": project.database,
"target_schema": project.test_schema,
"target_database": happy_path_project.database,
"target_schema": happy_path_project.test_schema,
"unique_key": "id",
"strategy": "timestamp",
"updated_at": "updated_at",
Expand Down Expand Up @@ -724,12 +710,12 @@ def expect_resource_type_env_var(self):
}
del os.environ["DBT_EXCLUDE_RESOURCE_TYPES"]

def expect_selected_keys(self, project):
def expect_selected_keys(self, happy_path_project): # noqa: F811
Copy link
Contributor

@QMalcolm QMalcolm Jun 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this test we're actually using the happy_path_project fixture argument in the function. Is the # noqa: F811 necessary for another reason?

"""Expect selected fields of the the selected model"""
expectations = [
{
"database": project.database,
"schema": project.test_schema,
"database": happy_path_project.database,
"schema": happy_path_project.test_schema,
"alias": "inner",
}
]
Expand All @@ -752,7 +738,9 @@ def expect_selected_keys(self, project):

"""Expect selected fields when --output-keys given multiple times
"""
expectations = [{"database": project.database, "schema": project.test_schema}]
expectations = [
{"database": happy_path_project.database, "schema": happy_path_project.test_schema}
]
results = self.run_dbt_ls(
[
"--model",
Expand Down
Loading