Skip to content

Commit

Permalink
test: add type annotations for web.Registry instances
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxdaemon committed May 7, 2024
1 parent cc8f655 commit 9445248
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
21 changes: 12 additions & 9 deletions tests/core_tests/util_tests/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_paste_error(mock_requests):


def test_registry_items():
registry = web.Registry()
registry = web.Registry[object]()
obj = object()
registry.register("test", obj)
item = registry.get_item("test")
Expand All @@ -57,9 +57,10 @@ def test_registry_items():


def test_registry_item_working(freeze_time):
registry = web.Registry()
registry = web.Registry[object]()
registry.register("test", object())
item = registry.get_item("test")
assert item is not None
assert item.should_use

item.failed()
Expand Down Expand Up @@ -271,18 +272,20 @@ def test_expand(mock_requests):
def test_register_duplicate_paste():
obj = object()
obj1 = object()
registry = web.Registry[object]()

web.pastebins.register("test", obj)
registry.register("test", obj)
with pytest.raises(ValueError):
web.pastebins.register("test", obj1)
registry.register("test", obj1)

web.pastebins.remove("test")
registry.remove("test")


def test_remove_paste():
obj = object()
registry = web.Registry[object]()

web.pastebins.register("test", obj)
assert web.pastebins.get("test") is obj
web.pastebins.remove("test")
assert web.pastebins.get("test") is None
registry.register("test", obj)
assert registry.get("test") is obj
registry.remove("test")
assert registry.get("test") is None
3 changes: 1 addition & 2 deletions tests/plugin_tests/test_admin_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ def f(self, attr):
event.__getitem__ = f
event.event = event

res = await func_utils.call_with_args(admin_bot.me, event)
assert res is None
await func_utils.call_with_args(admin_bot.me, event)
assert event.mock_calls == [
call.admin_log('bar used ME to make me ACT "do thing" in #foo.'),
call.conn.ctcp("#foo", "ACTION", "do thing"),
Expand Down

0 comments on commit 9445248

Please sign in to comment.