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

add predicate to EventCatcher test util #10482

Merged
merged 2 commits into from
Jul 23, 2024
Merged
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
5 changes: 3 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass, field
from typing import List
from typing import Callable, List

from dbt_common.events.base_types import BaseEvent, EventMsg

Expand All @@ -8,9 +8,10 @@
class EventCatcher:
event_to_catch: BaseEvent
caught_events: List[EventMsg] = field(default_factory=list)
predicate: Callable[[EventMsg], bool] = lambda event: True

def catch(self, event: EventMsg):
if event.info.name == self.event_to_catch.__name__:
if event.info.name == self.event_to_catch.__name__ and self.predicate(event):
self.caught_events.append(event)

def flush(self) -> None:
Expand Down
Loading