Skip to content

Commit

Permalink
Revert "Fix query comment tests (#7928) (#7928)"
Browse files Browse the repository at this point in the history
This reverts commit 015c490.
  • Loading branch information
dbeatty10 authored Jul 13, 2023
1 parent 015c490 commit 9cb1430
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
6 changes: 0 additions & 6 deletions .changes/unreleased/Fixes-20230623-092933.yaml

This file was deleted.

36 changes: 18 additions & 18 deletions tests/adapter/dbt/tests/adapter/query_comment/test_query_comment.py
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

0 comments on commit 9cb1430

Please sign in to comment.