Skip to content

Commit cad6c34

Browse files
committed
tests: add tests for restricted add_sub_controller method
1 parent ecaf5ec commit cad6c34

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tests/test_controller.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22

33
from fastcs.attributes import AttrR
4-
from fastcs.controller import Controller
4+
from fastcs.controller import Controller, ControllerVector
55
from fastcs.datatypes import Float, Int
66

77

@@ -101,3 +101,18 @@ def __init__(self):
101101
ValueError, match=r"Cannot add attribute .* existing sub controller"
102102
):
103103
controller.sub_controller = AttrR(Int()) # pyright: ignore[reportAttributeAccessIssue]
104+
105+
106+
def test_controller_raises_error_if_passed_numeric_sub_controller_name():
107+
sub_controller = SomeSubController()
108+
controller = SomeController(sub_controller)
109+
110+
with pytest.raises(ValueError, match="Numeric-only names are not allowed"):
111+
controller.add_sub_controller("30", sub_controller)
112+
113+
114+
def test_controller_vector_raises_error_if_add_sub_controller_called():
115+
controller_vector = ControllerVector({i: SomeSubController() for i in range(2)})
116+
117+
with pytest.raises(NotImplementedError, match="Use __setitem__ instead"):
118+
controller_vector.add_sub_controller("subcontroller", SomeSubController())

0 commit comments

Comments
 (0)