|
6 | 6 |
|
7 | 7 | from dqliteclient.connection import DqliteConnection |
8 | 8 | from dqliteclient.pool import ConnectionPool |
9 | | -from dqliteclient.protocol import DqliteProtocol, _validate_max_total_rows |
| 9 | +from dqliteclient.protocol import DqliteProtocol, _validate_positive_int_or_none |
10 | 10 |
|
11 | 11 |
|
12 | 12 | class TestValidator: |
13 | 13 | def test_none_allowed(self) -> None: |
14 | | - assert _validate_max_total_rows(None) is None |
| 14 | + assert _validate_positive_int_or_none(None, "max_total_rows") is None |
15 | 15 |
|
16 | 16 | def test_positive_int_allowed(self) -> None: |
17 | | - assert _validate_max_total_rows(1) == 1 |
18 | | - assert _validate_max_total_rows(10_000_000) == 10_000_000 |
| 17 | + assert _validate_positive_int_or_none(1, "max_total_rows") == 1 |
| 18 | + assert _validate_positive_int_or_none(10_000_000, "max_total_rows") == 10_000_000 |
19 | 19 |
|
20 | 20 | def test_zero_rejected(self) -> None: |
21 | 21 | with pytest.raises(ValueError, match="max_total_rows must be > 0"): |
22 | | - _validate_max_total_rows(0) |
| 22 | + _validate_positive_int_or_none(0, "max_total_rows") |
23 | 23 |
|
24 | 24 | def test_negative_rejected(self) -> None: |
25 | 25 | with pytest.raises(ValueError, match="max_total_rows must be > 0"): |
26 | | - _validate_max_total_rows(-1) |
| 26 | + _validate_positive_int_or_none(-1, "max_total_rows") |
27 | 27 |
|
28 | 28 | def test_float_rejected(self) -> None: |
29 | 29 | with pytest.raises(TypeError, match="max_total_rows must be int or None"): |
30 | | - _validate_max_total_rows(1.5) # type: ignore[arg-type] |
| 30 | + _validate_positive_int_or_none(1.5, "max_total_rows") # type: ignore[arg-type] |
31 | 31 |
|
32 | 32 | def test_bool_rejected(self) -> None: |
33 | 33 | # True is technically int, but PEP-489-style APIs rightly reject it. |
34 | 34 | with pytest.raises(TypeError, match="max_total_rows must be int or None"): |
35 | | - _validate_max_total_rows(True) # type: ignore[arg-type] |
| 35 | + _validate_positive_int_or_none(True, "max_total_rows") # type: ignore[arg-type] |
36 | 36 |
|
37 | 37 | def test_string_rejected(self) -> None: |
38 | 38 | with pytest.raises(TypeError, match="max_total_rows must be int or None"): |
39 | | - _validate_max_total_rows("100") # type: ignore[arg-type] |
| 39 | + _validate_positive_int_or_none("100", "max_total_rows") # type: ignore[arg-type] |
40 | 40 |
|
41 | 41 |
|
42 | 42 | class TestConstructorValidation: |
|
0 commit comments