|
5 | 5 | import pytest |
6 | 6 |
|
7 | 7 | import hebrew_numbers |
8 | | -from hebrew_numbers import ConstructState, GrammaticalGender, InvalidNumberError |
| 8 | +from hebrew_numbers import ( |
| 9 | + ConstructState, |
| 10 | + GrammaticalGender, |
| 11 | + InvalidNumberError, |
| 12 | + cardinal_number, |
| 13 | +) |
| 14 | +from hebrew_numbers.hebrew_numbers import _join_words |
9 | 15 |
|
10 | 16 | if TYPE_CHECKING: |
11 | 17 | from pytest_regressions.data_regression import DataRegressionFixture |
@@ -202,3 +208,49 @@ def test_over_10(gender: GrammaticalGender) -> None: |
202 | 208 | valid_exceptions=InvalidNumberError, |
203 | 209 | ) |
204 | 210 | ) |
| 211 | + |
| 212 | + |
| 213 | +class TestConstructStateFromBoolean: |
| 214 | + """Test ConstructState.from_boolean method edge cases.""" |
| 215 | + |
| 216 | + def test_from_boolean_with_construct_state_enum(self) -> None: |
| 217 | + """Test passing ConstructState enum directly returns same value.""" |
| 218 | + # This tests the else clause in from_boolean (line 68) |
| 219 | + result = ConstructState.from_boolean(ConstructState.ABSOLUTE) |
| 220 | + assert result == ConstructState.ABSOLUTE |
| 221 | + |
| 222 | + result = ConstructState.from_boolean(ConstructState.CONSTRUCT) |
| 223 | + assert result == ConstructState.CONSTRUCT |
| 224 | + |
| 225 | + |
| 226 | +class TestJoinWordsEdgeCases: |
| 227 | + """Test _join_words function with edge cases.""" |
| 228 | + |
| 229 | + def test_join_empty_words_list(self) -> None: |
| 230 | + """Test that empty words list raises ValueError.""" |
| 231 | + # This tests line 93 in hebrew_numbers.py |
| 232 | + with pytest.raises( |
| 233 | + ValueError, match="must contain at least one non-empty string" |
| 234 | + ): |
| 235 | + _join_words([]) |
| 236 | + |
| 237 | + def test_join_only_empty_strings(self) -> None: |
| 238 | + """Test that list with only empty strings raises ValueError.""" |
| 239 | + # This also tests line 93 in hebrew_numbers.py |
| 240 | + with pytest.raises( |
| 241 | + ValueError, match="must contain at least one non-empty string" |
| 242 | + ): |
| 243 | + _join_words(["", "", ""]) |
| 244 | + |
| 245 | + |
| 246 | +class TestCardinalNumberEdgeCases: |
| 247 | + """Test cardinal_number function with invalid inputs.""" |
| 248 | + |
| 249 | + def test_cardinal_number_invalid_range(self) -> None: |
| 250 | + """Test cardinal_number with numbers outside valid range.""" |
| 251 | + # Test zero (line 333 in hebrew_numbers.py) |
| 252 | + with pytest.raises(InvalidNumberError, match="Number must be positive"): |
| 253 | + cardinal_number(0, GrammaticalGender.MASCULINE, ConstructState.ABSOLUTE) |
| 254 | + |
| 255 | + with pytest.raises(InvalidNumberError, match="Number must be positive"): |
| 256 | + cardinal_number(-1, GrammaticalGender.MASCULINE, ConstructState.ABSOLUTE) |
0 commit comments