mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 01:05:48 +02:00
Add test for filtering
This commit is contained in:
@@ -685,11 +685,15 @@ class NotificationManager:
|
||||
return False
|
||||
return True
|
||||
|
||||
@property
|
||||
def filter_rules(self) -> Iterator[str]:
|
||||
return iter(get_options().filter_notification.keys())
|
||||
|
||||
def is_notification_filtered(self, cmd: NotificationCommand) -> bool:
|
||||
if self.filter_script(cmd):
|
||||
self.log(f'Notification {cmd.title!r} filtered out by script')
|
||||
return True
|
||||
for rule in get_options().filter_notification:
|
||||
for rule in self.filter_rules:
|
||||
if cmd.matches_rule(rule):
|
||||
self.log(f'Notification {cmd.title!r} filtered out by filter_notification rule: {rule}')
|
||||
return True
|
||||
|
||||
@@ -69,6 +69,13 @@ class Channel(Channel):
|
||||
self.responses.append(osc_escape_code)
|
||||
|
||||
|
||||
class NotificationManager(NotificationManager):
|
||||
|
||||
@property
|
||||
def filter_rules(self):
|
||||
yield from ('title:filterme',)
|
||||
|
||||
|
||||
def do_test(self: 'TestNotifications', tdir: str) -> None:
|
||||
di = DesktopIntegration(None)
|
||||
ch = Channel()
|
||||
@@ -162,6 +169,12 @@ def do_test(self: 'TestNotifications', tdir: str) -> None:
|
||||
self.ae(di.notifications, [n()])
|
||||
reset()
|
||||
|
||||
# test filtering
|
||||
h(';title')
|
||||
h(';filterme please')
|
||||
self.ae(di.notifications, [n()])
|
||||
reset()
|
||||
|
||||
# test closing interactions with reporting and activation
|
||||
h('i=c;title')
|
||||
self.ae(di.notifications, [n()])
|
||||
|
||||
Reference in New Issue
Block a user