| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
"""Unit tests for the asynceapi._constants module.""" |
| 5 |
|
| 6 |
import pytest |
| 7 |
|
| 8 |
from asynceapi._constants import EapiCommandFormat |
| 9 |
|
| 10 |
|
| 11 |
class TestEapiCommandFormat: |
| 12 |
"""Test cases for the EapiCommandFormat enum.""" |
| 13 |
|
| 14 |
def test_enum_values(self) -> None: |
| 15 |
"""Test that the enum has the expected values.""" |
| 16 |
assert EapiCommandFormat.JSON.value == "json" |
| 17 |
assert EapiCommandFormat.TEXT.value == "text" |
| 18 |
|
| 19 |
def test_str_method(self) -> None: |
| 20 |
"""Test that the __str__ method returns the string value.""" |
| 21 |
assert str(EapiCommandFormat.JSON) == "json" |
| 22 |
assert str(EapiCommandFormat.TEXT) == "text" |
| 23 |
|
| 24 |
|
| 25 |
assert f"Format: {EapiCommandFormat.JSON}" == "Format: json" |
| 26 |
|
| 27 |
def test_string_behavior(self) -> None: |
| 28 |
"""Test that the enum behaves like a string.""" |
| 29 |
|
| 30 |
assert EapiCommandFormat.JSON.upper() == "JSON" |
| 31 |
|
| 32 |
|
| 33 |
assert EapiCommandFormat.JSON == "json" |
| 34 |
assert EapiCommandFormat.TEXT == "text" |
| 35 |
|
| 36 |
def test_enum_lookup(self) -> None: |
| 37 |
"""Test enum lookup by value.""" |
| 38 |
assert EapiCommandFormat("json") is EapiCommandFormat.JSON |
| 39 |
assert EapiCommandFormat("text") is EapiCommandFormat.TEXT |
| 40 |
|
| 41 |
with pytest.raises(ValueError, match="'invalid' is not a valid EapiCommandFormat"): |
| 42 |
EapiCommandFormat("invalid") |