feat: add tests and better model validation for gesture commands
ref: N25B-334
This commit is contained in:
@@ -21,7 +21,21 @@ def invalid_command_1():
|
||||
|
||||
|
||||
def invalid_command_2():
|
||||
return GestureCommand(endpoint=RIEndpoint.PING, data="Hey!")
|
||||
return RIMessage(endpoint=RIEndpoint.PING, data="Hey!")
|
||||
|
||||
|
||||
def invalid_command_3():
|
||||
return RIMessage(endpoint=RIEndpoint.GESTURE_SINGLE, data={1, 2, 3})
|
||||
|
||||
|
||||
def invalid_command_4():
|
||||
test: RIMessage = GestureCommand(endpoint=RIEndpoint.GESTURE_SINGLE, data="asdsad")
|
||||
|
||||
def change_endpoint(msg: RIMessage):
|
||||
msg.endpoint = RIEndpoint.PING
|
||||
|
||||
change_endpoint(test)
|
||||
return test
|
||||
|
||||
|
||||
def test_valid_speech_command_1():
|
||||
@@ -56,3 +70,19 @@ def test_invalid_gesture_command_1():
|
||||
|
||||
with pytest.raises(ValidationError):
|
||||
GestureCommand.model_validate(command)
|
||||
|
||||
|
||||
def test_invalid_gesture_command_2():
|
||||
command = invalid_command_3()
|
||||
RIMessage.model_validate(command)
|
||||
|
||||
with pytest.raises(ValidationError):
|
||||
GestureCommand.model_validate(command)
|
||||
|
||||
|
||||
def test_invalid_gesture_command_3():
|
||||
command = invalid_command_4()
|
||||
RIMessage.model_validate(command)
|
||||
|
||||
with pytest.raises(ValidationError):
|
||||
GestureCommand.model_validate(command)
|
||||
|
||||
Reference in New Issue
Block a user