allow strings or functions for tab filter function in python module

This commit is contained in:
2026-04-09 23:51:02 +02:00
parent c5a4218da0
commit 172ba73697
2 changed files with 42 additions and 3 deletions
+11
View File
@@ -238,6 +238,17 @@ class TestTabs:
mock_send.return_value = None
assert b.tabs_filter("x") == []
def test_tabs_filter_predicate(self, b, mock_send):
mock_send.return_value = [TAB_DATA, {**TAB_DATA, "id": 11, "url": "https://youtube.com"}]
tabs = b.tabs_filter(lambda tab: "youtube" in tab.url)
print(tabs)
assert [tab.id for tab in tabs] == [11]
def test_tabs_filter_list_transformer(self, b, mock_send):
mock_send.return_value = [TAB_DATA, {**TAB_DATA, "id": 11, "url": "https://example.com"}]
tabs = b.tabs_filter(lambda tabs: tabs[:1])
assert [tab.id for tab in tabs] == [10]
def test_tabs_count(self, b, mock_send):
mock_send.return_value = 5
assert b.tabs_count() == 5