-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Standalone test
- Loading branch information
Showing
3 changed files
with
34 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import asyncio | ||
import logging | ||
|
||
import pytest | ||
|
||
from pyobs.modules.test import StandAlone | ||
|
||
|
||
def test_default(): | ||
module = StandAlone() | ||
assert module._message == "Hello world" | ||
assert module._interval == 10 | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_loop(mocker, caplog): | ||
mocker.patch("asyncio.sleep", return_value=None) | ||
module = StandAlone("Testmessage", 3) | ||
|
||
with caplog.at_level(logging.INFO): | ||
await module._loop() | ||
|
||
assert caplog.messages[0] == "Testmessage" | ||
asyncio.sleep.assert_called_once_with(3) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_background_task(): | ||
module = StandAlone() | ||
assert module._message_func in module._background_tasks |