mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-21 16:50:02 +02:00
adds test for dynamic list entries with properties
This commit is contained in:
parent
dc42bfaa9b
commit
dfb6f966aa
@ -94,3 +94,31 @@ def test_protected_or_private_change_logs(caplog: pytest.LogCaptureFixture) -> N
|
||||
|
||||
service.subclass._name = "Hello"
|
||||
assert "'subclass._name' changed to 'Hello'" not in caplog.text
|
||||
|
||||
|
||||
def test_dynamic_list_entry_with_property(caplog: pytest.LogCaptureFixture) -> None:
|
||||
class PropertyClass(pydase.DataService):
|
||||
_name = "Hello"
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
"""The name property."""
|
||||
return self._name
|
||||
|
||||
class MyService(pydase.DataService):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.list_attr = []
|
||||
|
||||
def toggle_high_voltage(self) -> None:
|
||||
self.list_attr = []
|
||||
self.list_attr.append(PropertyClass())
|
||||
self.list_attr[0]._name = "Hoooo"
|
||||
|
||||
service = MyService()
|
||||
state_manager = StateManager(service)
|
||||
DataServiceObserver(state_manager)
|
||||
service.toggle_high_voltage()
|
||||
|
||||
assert "'list_attr[0].name' changed to 'Hello'" not in caplog.text
|
||||
assert "'list_attr[0].name' changed to 'Hoooo'" in caplog.text
|
||||
|
Loading…
x
Reference in New Issue
Block a user