aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_sleep.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_sleep.py')
-rw-r--r--tests/test_sleep.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_sleep.py b/tests/test_sleep.py
new file mode 100644
index 0000000..c226c47
--- /dev/null
+++ b/tests/test_sleep.py
@@ -0,0 +1,22 @@
+from unittest.mock import MagicMock, patch
+
+import pytest
+import weechat
+
+from slack import FutureTimer, sleep, weechat_task_cb
+
+
+@patch.object(weechat, "hook_timer")
+def test_sleep(mock_method: MagicMock):
+ milliseconds = 123
+ coroutine = sleep(milliseconds)
+ future = coroutine.send(None)
+ assert isinstance(future, FutureTimer)
+
+ mock_method.assert_called_once_with(
+ milliseconds, 0, 1, weechat_task_cb.__name__, future.id
+ )
+
+ with pytest.raises(StopIteration) as excinfo:
+ coroutine.send((0,))
+ assert excinfo.value.value == (0,) # TODO: Will probably change to None