27 lines
644 B
Python
27 lines
644 B
Python
import pytest
|
|
from pydantic import ValidationError
|
|
|
|
from control_backend.schemas.ri_message import RIEndpoint, RIMessage, SpeechCommand
|
|
|
|
|
|
def valid_command_1():
|
|
return SpeechCommand(data="Hallo?")
|
|
|
|
|
|
def invalid_command_1():
|
|
return RIMessage(endpoint=RIEndpoint.PING, data="Hello again.")
|
|
|
|
|
|
def test_valid_speech_command_1():
|
|
command = valid_command_1()
|
|
RIMessage.model_validate(command)
|
|
SpeechCommand.model_validate(command)
|
|
|
|
|
|
def test_invalid_speech_command_1():
|
|
command = invalid_command_1()
|
|
RIMessage.model_validate(command)
|
|
|
|
with pytest.raises(ValidationError):
|
|
SpeechCommand.model_validate(command)
|