generated from dbt-labs/dbt-oss-template
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into move_catalog_schema
- Loading branch information
Showing
20 changed files
with
512 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Features | ||
body: Support adding callbacks to the event manager | ||
time: 2024-05-14T16:20:52.120336-07:00 | ||
custom: | ||
Author: QMalcolm | ||
Issue: "131" |
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,6 @@ | ||
kind: Features | ||
body: Add a print event to support firing event to console in --quiet mode | ||
time: 2024-05-15T16:11:06.815526-07:00 | ||
custom: | ||
Author: ChenyuLInx | ||
Issue: "8756" |
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 |
---|---|---|
@@ -1 +1 @@ | ||
version = "1.0.4" | ||
version = "1.1.0" |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Empty file.
Empty file.
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,40 @@ | ||
import json | ||
from dbt_common.events.logger import LoggerConfig, _TextLogger, _JsonLogger | ||
from dbt_common.events.base_types import EventLevel, msg_from_base_event | ||
from dbt_common.events.types import PrintEvent | ||
|
||
|
||
def test_create_print_line(): | ||
# No format, still fired even when error is the level | ||
config = LoggerConfig(name="test_logger", level=EventLevel.ERROR) | ||
logger = _TextLogger(config) | ||
msg = msg_from_base_event(PrintEvent(msg="This is a print event")) | ||
expected_line = "This is a print event" | ||
actual_line = logger.create_line(msg) | ||
assert actual_line == expected_line | ||
|
||
|
||
def test_create_print_json(): | ||
# JSON format still have event level being info | ||
config = LoggerConfig(name="test_logger", level=EventLevel.ERROR) | ||
logger = _JsonLogger(config) | ||
msg = msg_from_base_event(PrintEvent(msg="This is a print event")) | ||
expected_json = { | ||
"data": {"msg": "This is a print event"}, | ||
"info": { | ||
"category": "", | ||
"code": "Z052", | ||
"extra": {}, | ||
"level": "info", | ||
"msg": "This is a print event", | ||
"name": "PrintEvent", | ||
"thread": "MainThread", | ||
}, | ||
} | ||
actual_line = logger.create_line(msg) | ||
actual_json = json.loads(actual_line) | ||
assert "info" in actual_json | ||
actual_json["info"].pop("invocation_id") | ||
actual_json["info"].pop("ts") | ||
actual_json["info"].pop("pid") | ||
assert actual_json == expected_json |
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,11 @@ | ||
from dbt_common.events.event_manager import EventManager | ||
from tests.unit.utils import EventCatcher | ||
|
||
|
||
class TestEventManager: | ||
def test_add_callback(self) -> None: | ||
event_manager = EventManager() | ||
assert len(event_manager.callbacks) == 0 | ||
|
||
event_manager.add_callback(EventCatcher().catch) | ||
assert len(event_manager.callbacks) == 1 |
Oops, something went wrong.