MCPcopy Create free account
hub / github.com/anomalyco/opencode-sdk-python / test_iso8601_format

Function test_iso8601_format

tests/test_transform.py:190–205  ·  view source on GitHub ↗
(use_async: bool)

Source from the content-addressed store, hash-verified

188@parametrize
189@pytest.mark.asyncio
190async def test_iso8601_format(use_async: bool) -> None:
191 dt = datetime.fromisoformat("2023-02-23T14:16:36.337692+00:00")
192 tz = "Z" if PYDANTIC_V2 else "+00:00"
193 assert await transform({"foo": dt}, DatetimeDict, use_async) == {"foo": "2023-02-23T14:16:36.337692+00:00"} # type: ignore[comparison-overlap]
194 assert await transform(DatetimeModel(foo=dt), Any, use_async) == {"foo": "2023-02-23T14:16:36.337692" + tz} # type: ignore[comparison-overlap]
195
196 dt = dt.replace(tzinfo=None)
197 assert await transform({"foo": dt}, DatetimeDict, use_async) == {"foo": "2023-02-23T14:16:36.337692"} # type: ignore[comparison-overlap]
198 assert await transform(DatetimeModel(foo=dt), Any, use_async) == {"foo": "2023-02-23T14:16:36.337692"} # type: ignore[comparison-overlap]
199
200 assert await transform({"foo": None}, DateDict, use_async) == {"foo": None} # type: ignore[comparison-overlap]
201 assert await transform(DateModel(foo=None), Any, use_async) == {"foo": None} # type: ignore
202 assert await transform({"foo": date.fromisoformat("2023-02-23")}, DateDict, use_async) == {"foo": "2023-02-23"} # type: ignore[comparison-overlap]
203 assert await transform(DateModel(foo=date.fromisoformat("2023-02-23")), DateDict, use_async) == {
204 "foo": "2023-02-23"
205 } # type: ignore[comparison-overlap]
206
207
208@parametrize

Callers

nothing calls this directly

Calls 3

DatetimeModelClass · 0.85
DateModelClass · 0.85
transformFunction · 0.70

Tested by

no test coverage detected