mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-06-05 21:20:40 +02:00
updates some tests to have a running event loop
This commit is contained in:
parent
c733026522
commit
f69723dd58
@ -1,6 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import pydase
|
import pydase
|
||||||
|
import pytest
|
||||||
from pydase.data_service.data_service_observer import DataServiceObserver
|
from pydase.data_service.data_service_observer import DataServiceObserver
|
||||||
from pydase.data_service.state_manager import StateManager
|
from pydase.data_service.state_manager import StateManager
|
||||||
|
|
||||||
@ -34,7 +35,8 @@ def test_nested_attributes_cache_callback() -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_task_status_update() -> None:
|
@pytest.mark.asyncio
|
||||||
|
async def test_task_status_update() -> None:
|
||||||
class ServiceClass(pydase.DataService):
|
class ServiceClass(pydase.DataService):
|
||||||
name = "World"
|
name = "World"
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import pydase
|
import pydase
|
||||||
|
import pytest
|
||||||
from pydase.data_service.data_service_observer import DataServiceObserver
|
from pydase.data_service.data_service_observer import DataServiceObserver
|
||||||
from pydase.data_service.state_manager import StateManager
|
from pydase.data_service.state_manager import StateManager
|
||||||
from pytest import LogCaptureFixture
|
from pytest import LogCaptureFixture
|
||||||
@ -8,13 +9,14 @@ from pytest import LogCaptureFixture
|
|||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
def test_autostart_task_callback(caplog: LogCaptureFixture) -> None:
|
@pytest.mark.asyncio
|
||||||
|
async def test_autostart_task_callback(caplog: LogCaptureFixture) -> None:
|
||||||
class MyService(pydase.DataService):
|
class MyService(pydase.DataService):
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._autostart_tasks = { # type: ignore
|
self._autostart_tasks = { # type: ignore
|
||||||
"my_task": (),
|
"my_task": (), # type: ignore
|
||||||
"my_other_task": (),
|
"my_other_task": (), # type: ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
async def my_task(self) -> None:
|
async def my_task(self) -> None:
|
||||||
@ -23,6 +25,7 @@ def test_autostart_task_callback(caplog: LogCaptureFixture) -> None:
|
|||||||
async def my_other_task(self) -> None:
|
async def my_other_task(self) -> None:
|
||||||
logger.info("Triggered other task.")
|
logger.info("Triggered other task.")
|
||||||
|
|
||||||
|
# Your test code here
|
||||||
service_instance = MyService()
|
service_instance = MyService()
|
||||||
state_manager = StateManager(service_instance)
|
state_manager = StateManager(service_instance)
|
||||||
DataServiceObserver(state_manager)
|
DataServiceObserver(state_manager)
|
||||||
@ -32,7 +35,8 @@ def test_autostart_task_callback(caplog: LogCaptureFixture) -> None:
|
|||||||
assert "'my_other_task' changed to '{}'" in caplog.text
|
assert "'my_other_task' changed to '{}'" in caplog.text
|
||||||
|
|
||||||
|
|
||||||
def test_DataService_subclass_autostart_task_callback(
|
@pytest.mark.asyncio
|
||||||
|
async def test_DataService_subclass_autostart_task_callback(
|
||||||
caplog: LogCaptureFixture,
|
caplog: LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
class MySubService(pydase.DataService):
|
class MySubService(pydase.DataService):
|
||||||
@ -61,7 +65,8 @@ def test_DataService_subclass_autostart_task_callback(
|
|||||||
assert "'sub_service.my_other_task' changed to '{}'" in caplog.text
|
assert "'sub_service.my_other_task' changed to '{}'" in caplog.text
|
||||||
|
|
||||||
|
|
||||||
def test_DataService_subclass_list_autostart_task_callback(
|
@pytest.mark.asyncio
|
||||||
|
async def test_DataService_subclass_list_autostart_task_callback(
|
||||||
caplog: LogCaptureFixture,
|
caplog: LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
class MySubService(pydase.DataService):
|
class MySubService(pydase.DataService):
|
||||||
|
@ -125,7 +125,8 @@ def test_ColouredEnum_serialize() -> None:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_method_serialization() -> None:
|
@pytest.mark.asyncio
|
||||||
|
async def test_method_serialization() -> None:
|
||||||
class ClassWithMethod(pydase.DataService):
|
class ClassWithMethod(pydase.DataService):
|
||||||
def some_method(self) -> str:
|
def some_method(self) -> str:
|
||||||
return "some method"
|
return "some method"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user