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

Revert "Fix query comment tests" #8093

Closed
wants to merge 1 commit into from
Closed
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: 0 additions & 6 deletions .changes/unreleased/Fixes-20230623-092933.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,44 +28,46 @@ def run_get_json(self, expect_pass=True):
assert len(res) > 0
return raw_logs

def run_assert_comments(self):
logs = self.run_get_json()
return logs

def test_comments(self, project):
self.run_assert_comments()


# Base setup to be inherited #
class BaseQueryComments(BaseDefaultQueryComments):
@pytest.fixture(scope="class")
def project_config_update(self):
return {"query-comment": "dbt\nrules!\n"}

def test_matches_comment(self, project) -> bool:
logs = self.run_get_json()
assert r"/* dbt\nrules! */\n" in logs
def matches_comment(self, logs) -> bool:
assert "/* dbt\nrules! */\n" in logs


class BaseMacroQueryComments(BaseDefaultQueryComments):
@pytest.fixture(scope="class")
def project_config_update(self):
return {"query-comment": "{{ query_header_no_args() }}"}

def test_matches_comment(self, project) -> bool:
logs = self.run_get_json()
assert r"/* dbt macros\nare pretty cool */\n" in logs
def matches_comment(self, logs) -> bool:
assert "/* dbt macros\nare pretty cool */\n" in logs


class BaseMacroArgsQueryComments(BaseDefaultQueryComments):
@pytest.fixture(scope="class")
def project_config_update(self):
return {"query-comment": "{{ return(ordered_to_json(query_header_args(target.name))) }}"}

def test_matches_comment(self, project) -> bool:
logs = self.run_get_json()
def matches_comment(self, logs) -> bool:
expected_dct = {
"app": "dbt++",
"dbt_version": dbt_version,
"macro_version": "0.1.0",
"message": f"blah: {project.adapter.config.target_name}",
"message": "blah: default2",
}
expected = r"/* {} */\n".format(json.dumps(expected_dct, sort_keys=True)).replace(
'"', r"\""
)
expected = "/* {} */\n".format(json.dumps(expected_dct, sort_keys=True))
assert expected in logs


Expand All @@ -74,18 +76,17 @@ class BaseMacroInvalidQueryComments(BaseDefaultQueryComments):
def project_config_update(self):
return {"query-comment": "{{ invalid_query_header() }}"}

def test_run_assert_comments(self, project):
def run_assert_comments(self):
with pytest.raises(DbtRuntimeError):
self.run_get_json(expect_pass=False)


class BaseNullQueryComments(BaseDefaultQueryComments):
@pytest.fixture(scope="class")
def project_config_update(self):
return {"query-comment": None}
return {"query-comment": ""}

def test_matches_comment(self, project) -> bool:
logs = self.run_get_json()
def matches_comment(self, logs) -> bool:
assert "/*" not in logs or "*/" not in logs


Expand All @@ -94,8 +95,7 @@ class BaseEmptyQueryComments(BaseDefaultQueryComments):
def project_config_update(self):
return {"query-comment": ""}

def test_matches_comment(self, project) -> bool:
logs = self.run_get_json()
def matches_comment(self, logs) -> bool:
assert "/*" not in logs or "*/" not in logs


Expand Down