|
2 | 2 | These tests exercise the custom enum methods using arbitrary enum values. |
3 | 3 | """ |
4 | 4 |
|
| 5 | +import pytest |
| 6 | + |
5 | 7 | from roborock.data.b01_q10.b01_q10_code_mappings import B01_Q10_DP |
6 | 8 |
|
7 | 9 |
|
8 | | -def test_from_code(): |
| 10 | +def test_from_code() -> None: |
9 | 11 | """Test from_code method.""" |
10 | 12 | assert B01_Q10_DP.START_CLEAN == B01_Q10_DP.from_code(201) |
11 | 13 | assert B01_Q10_DP.PAUSE == B01_Q10_DP.from_code(204) |
12 | 14 | assert B01_Q10_DP.STOP == B01_Q10_DP.from_code(206) |
13 | 15 |
|
14 | 16 |
|
15 | | -def test_from_name(): |
| 17 | +def test_invalid_from_code() -> None: |
| 18 | + """Test invalid from_code method.""" |
| 19 | + with pytest.raises(ValueError, match="999999 is not a valid code for B01_Q10_DP") as ex: |
| 20 | + B01_Q10_DP.from_code(999999) |
| 21 | + |
| 22 | + |
| 23 | +def test_from_name() -> None: |
16 | 24 | """Test from_name method.""" |
17 | 25 | assert B01_Q10_DP.START_CLEAN == B01_Q10_DP.from_name("START_CLEAN") |
18 | 26 | assert B01_Q10_DP.PAUSE == B01_Q10_DP.from_name("pause") |
19 | 27 | assert B01_Q10_DP.STOP == B01_Q10_DP.from_name("Stop") |
20 | 28 |
|
21 | 29 |
|
22 | | -def test_from_value(): |
| 30 | +def test_invalid_from_name() -> None: |
| 31 | + """Test invalid from_name method.""" |
| 32 | + with pytest.raises(ValueError, match="INVALID_NAME is not a valid name for B01_Q10_DP") as ex: |
| 33 | + B01_Q10_DP.from_name("INVALID_NAME") |
| 34 | + |
| 35 | + |
| 36 | +def test_from_value() -> None: |
23 | 37 | """Test from_value method.""" |
24 | 38 | assert B01_Q10_DP.START_CLEAN == B01_Q10_DP.from_value("dpStartClean") |
25 | 39 | assert B01_Q10_DP.PAUSE == B01_Q10_DP.from_value("dpPause") |
26 | 40 | assert B01_Q10_DP.STOP == B01_Q10_DP.from_value("dpStop") |
| 41 | + |
| 42 | + |
| 43 | +def test_invalid_from_value() -> None: |
| 44 | + """Test invalid from_value method.""" |
| 45 | + with pytest.raises(ValueError, match="invalid_value is not a valid value for B01_Q10_DP") as ex: |
| 46 | + B01_Q10_DP.from_value("invalid_value") |
0 commit comments