@@ -981,3 +981,56 @@ def test_persisted_action_group_id_property_returns_str(self):
981981 result = group .id
982982 assert isinstance (result , str )
983983 assert result == "abc-123"
984+
985+
986+ def test_get_command_definition_found ():
987+ """Device.get_command_definition() returns CommandDefinition when command exists."""
988+ from pyoverkiz .models import CommandDefinition
989+
990+ device = _make_device (
991+ {
992+ ** RAW_DEVICES ,
993+ "definition" : {
994+ ** RAW_DEVICES ["definition" ],
995+ "commands" : [{"commandName" : "open" , "nparams" : 0 }],
996+ },
997+ }
998+ )
999+ cd = device .get_command_definition ("open" )
1000+ assert cd is not None
1001+ assert isinstance (cd , CommandDefinition )
1002+ assert cd .nparams == 0
1003+
1004+
1005+ def test_get_command_definition_not_found ():
1006+ """Device.get_command_definition() returns None when command doesn't exist."""
1007+ device = _make_device (
1008+ {
1009+ ** RAW_DEVICES ,
1010+ "definition" : {
1011+ ** RAW_DEVICES ["definition" ],
1012+ "commands" : [],
1013+ },
1014+ }
1015+ )
1016+ assert device .get_command_definition ("open" ) is None
1017+
1018+
1019+ def test_get_command_definition_no_definition ():
1020+ """Device.get_command_definition() returns None when device has no definition."""
1021+ from pyoverkiz .enums import ProductType
1022+ from pyoverkiz .models import States
1023+
1024+ device = Device (
1025+ attributes = States (),
1026+ available = True ,
1027+ enabled = True ,
1028+ label = "Test" ,
1029+ device_url = "io://1234-5678-9012/1" ,
1030+ controllable_name = "test" ,
1031+ definition = None ,
1032+ type = ProductType .ACTUATOR ,
1033+ widget = "SomeWidget" ,
1034+ ui_class = "RollerShutter" ,
1035+ )
1036+ assert device .get_command_definition ("open" ) is None
0 commit comments