Skip to content

Commit a97129d

Browse files
committed
add a couple more tests to datetime interval; synch pytest versions
1 parent 9c212cb commit a97129d

4 files changed

Lines changed: 27 additions & 5 deletions

File tree

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ dependencies = [
1515
dev = [
1616
"pytest>=8.1.1",
1717
"mypy>=1.15.0",
18-
"pytest>=8.3.5",
1918
"ruff>=0.11.2",
2019
"pymarkdownlnt>=0.9.25",
2120
"pre-commit>=4.2.0",

stapi-pydantic/pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,8 @@ include = ["src/stapi_pydantic"]
2525
[build-system]
2626
requires = ["hatchling"]
2727
build-backend = "hatchling.build"
28+
29+
[dependency-groups]
30+
dev = [
31+
"pytest>=8.1.1",
32+
]
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1+
import pytest
12
from stapi_pydantic import DatetimeInterval
23

34

4-
def test_datetime_interval() -> None:
5+
def test_valid_datetime_intervals() -> None:
56
"""Test the datetime interval validator."""
67
dt1 = DatetimeInterval.__metadata__[0].func("2025-04-01T00:00:00Z/2025-04-01T23:59:59Z")
7-
dt2 = DatetimeInterval.__metadata__[0].func("2025-04-01T00:00:00Z/..")
8-
dt3 = DatetimeInterval.__metadata__[0].func("../2025-04-01T23:59:59Z")
98
_ = DatetimeInterval.__metadata__[1].func(dt1)
9+
dt2 = DatetimeInterval.__metadata__[0].func("2025-04-01T00:00:00Z/..")
1010
_ = DatetimeInterval.__metadata__[1].func(dt2)
11+
dt3 = DatetimeInterval.__metadata__[0].func("../2025-04-01T23:59:59Z")
1112
_ = DatetimeInterval.__metadata__[1].func(dt3)
13+
dt4 = DatetimeInterval.__metadata__[0].func("../..")
14+
_ = DatetimeInterval.__metadata__[1].func(dt4)
15+
16+
17+
def test_invalid_datetime_intervals() -> None:
18+
"""Test the datetime interval validator."""
19+
with pytest.raises(ValueError, match="end before start"):
20+
dt1 = DatetimeInterval.__metadata__[0].func("2025-04-01T00:00:00Z/2025-03-01T23:59:59Z")
21+
_ = DatetimeInterval.__metadata__[1].func(dt1)
22+

uv.lock

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)