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 cl/print_event
- Loading branch information
Showing
12 changed files
with
69 additions
and
17 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
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
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,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 |
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,15 @@ | ||
from pytest_mock import MockerFixture | ||
|
||
from dbt_common.events.event_manager import EventManager | ||
from dbt_common.events.event_manager_client import add_callback_to_manager, get_event_manager | ||
from tests.unit.utils import EventCatcher | ||
|
||
|
||
def test_add_callback_to_manager(mocker: MockerFixture) -> None: | ||
# mock out the global event manager so the callback doesn't get added to all other tests | ||
mocker.patch("dbt_common.events.event_manager_client._EVENT_MANAGER", EventManager()) | ||
manager = get_event_manager() | ||
assert len(manager.callbacks) == 0 | ||
|
||
add_callback_to_manager(EventCatcher().catch) | ||
assert len(manager.callbacks) == 1 |
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,12 @@ | ||
from dataclasses import dataclass, field | ||
from typing import List | ||
|
||
from dbt_common.events.base_types import EventMsg | ||
|
||
|
||
@dataclass | ||
class EventCatcher: | ||
caught_events: List[EventMsg] = field(default_factory=list) | ||
|
||
def catch(self, event: EventMsg) -> None: | ||
self.caught_events.append(event) |