updates tests

This commit is contained in:
Mose Müller
2023-11-30 17:17:41 +01:00
parent cc105106ee
commit c891642bda
10 changed files with 563 additions and 465 deletions

View File

@ -1,8 +1,7 @@
import logging
from pytest import LogCaptureFixture
import pydase
from pytest import LogCaptureFixture
logger = logging.getLogger()
@ -10,11 +9,11 @@ logger = logging.getLogger()
def test_autostart_task_callback(caplog: LogCaptureFixture) -> None:
class MyService(pydase.DataService):
def __init__(self) -> None:
super().__init__()
self._autostart_tasks = { # type: ignore
"my_task": (),
"my_other_task": (),
}
super().__init__()
async def my_task(self) -> None:
logger.info("Triggered task.")
@ -25,8 +24,8 @@ def test_autostart_task_callback(caplog: LogCaptureFixture) -> None:
service = MyService()
service._task_manager.start_autostart_tasks()
assert "MyService.my_task changed to {}" in caplog.text
assert "MyService.my_other_task changed to {}" in caplog.text
assert "'my_task' changed to '{}'" in caplog.text
assert "'my_other_task' changed to '{}'" in caplog.text
def test_DataService_subclass_autostart_task_callback(
@ -34,11 +33,11 @@ def test_DataService_subclass_autostart_task_callback(
) -> None:
class MySubService(pydase.DataService):
def __init__(self) -> None:
super().__init__()
self._autostart_tasks = { # type: ignore
"my_task": (),
"my_other_task": (),
}
super().__init__()
async def my_task(self) -> None:
logger.info("Triggered task.")
@ -52,8 +51,8 @@ def test_DataService_subclass_autostart_task_callback(
service = MyService()
service._task_manager.start_autostart_tasks()
assert "MyService.sub_service.my_task changed to {}" in caplog.text
assert "MyService.sub_service.my_other_task changed to {}" in caplog.text
assert "'sub_service.my_task' changed to '{}'" in caplog.text
assert "'sub_service.my_other_task' changed to '{}'" in caplog.text
def test_DataServiceList_subclass_autostart_task_callback(
@ -61,11 +60,11 @@ def test_DataServiceList_subclass_autostart_task_callback(
) -> None:
class MySubService(pydase.DataService):
def __init__(self) -> None:
super().__init__()
self._autostart_tasks = { # type: ignore
"my_task": (),
"my_other_task": (),
}
super().__init__()
async def my_task(self) -> None:
logger.info("Triggered task.")
@ -79,7 +78,7 @@ def test_DataServiceList_subclass_autostart_task_callback(
service = MyService()
service._task_manager.start_autostart_tasks()
assert "MyService.sub_services_list[0].my_task changed to {}" in caplog.text
assert "MyService.sub_services_list[0].my_other_task changed to {}" in caplog.text
assert "MyService.sub_services_list[1].my_task changed to {}" in caplog.text
assert "MyService.sub_services_list[1].my_other_task changed to {}" in caplog.text
assert "'sub_services_list[0].my_task' changed to '{}'" in caplog.text
assert "'sub_services_list[0].my_other_task' changed to '{}'" in caplog.text
assert "'sub_services_list[1].my_task' changed to '{}'" in caplog.text
assert "'sub_services_list[1].my_other_task' changed to '{}'" in caplog.text