updates tests

This commit is contained in:
Mose Müller
2023-12-04 17:23:42 +01:00
parent 0aa1595da4
commit 89b5a9cc9e
5 changed files with 321 additions and 324 deletions

View File

@ -51,7 +51,7 @@ def test_convert_to_quantity() -> None:
assert u.convert_to_quantity(1.0 * u.units.mV) == 1.0 * u.units.mV
def test_update_DataService_attribute(caplog: LogCaptureFixture) -> None:
def test_set_service_attribute_value_by_path(caplog: LogCaptureFixture) -> None:
class ServiceClass(DataService):
voltage = 1.0 * u.units.V
_current: u.Quantity = 1.0 * u.units.mA
@ -68,20 +68,20 @@ def test_update_DataService_attribute(caplog: LogCaptureFixture) -> None:
state_manager = StateManager(service_instance)
DataServiceObserver(state_manager)
service_instance.update_DataService_attribute(
path_list=[], attr_name="voltage", value=1.0 * u.units.mV
state_manager.set_service_attribute_value_by_path(
path="voltage", value=1.0 * u.units.mV
)
assert "'voltage' changed to '1.0 mV'" in caplog.text
caplog.clear()
service_instance.update_DataService_attribute(path_list=[], attr_name="voltage", value=2)
state_manager.set_service_attribute_value_by_path(path="voltage", value=2)
assert "'voltage' changed to '2.0 mV'" in caplog.text
caplog.clear()
service_instance.update_DataService_attribute(
path_list=[], attr_name="voltage", value={"magnitude": 123, "unit": "kV"}
state_manager.set_service_attribute_value_by_path(
path="voltage", value={"magnitude": 123, "unit": "kV"}
)
assert "'voltage' changed to '123.0 kV'" in caplog.text