Skip to content

Commit

Permalink
Shore up HexColor tests for my paranoia.
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxColoring committed Dec 12, 2024
1 parent 6f5cdba commit f8263cb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions api/tests/opentrons/protocol_engine/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ def test_hex_validation(hex_color: str) -> None:
"""Should allow creating a HexColor."""
# make sure noting is raised when instantiating this class
assert HexColor(hex_color)
assert HexColor.model_validate_json(f'"{hex_color}"')


def test_handles_invalid_hex() -> None:
@pytest.mark.parametrize("invalid_hex_color", ["true", "null", "#123456789"])
def test_handles_invalid_hex(invalid_hex_color: str) -> None:
"""Should raise a validation error."""
with pytest.raises(ValidationError):
HexColor("#123456789")
HexColor(invalid_hex_color)
with pytest.raises(ValidationError):
HexColor.model_validate_json(f'"{invalid_hex_color}"')

0 comments on commit f8263cb

Please sign in to comment.