mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-01-06 08:49:53 -06:00
Feat: Top-level stream consumer in the SDKs (#1917)
* feat: add stream sub on top level * feat: clean up examples * chore: gen * feat: move stream onto the runs client in ts * fix: examples * chore: gen * fix: circular import issues * chore: lint * feat: first pass at Next app * fix: pull next out to top level * fix: all the things * fix: get it all wired up * fix: imports * fix: lint rule * fix: just use js * fix: revert tsconfig changes * fix: check in pages * fix: hangup event in streaming impl * chore: gen * chore: generate again, remove lots of nextjs stuff * fix: one more ignore * fix: gen * fix: ignore * fix: ugh * fix: simplify a bunch * fix: lint * fix: rm gen cruft * fix: changelog * feat: implement list with pagination * feat: add some tests * feat: add warnings * fix: update workflow / task methods * chore: version * feat: retries
This commit is contained in:
67
sdks/python/tests/test_datetime_partitioning.py
Normal file
67
sdks/python/tests/test_datetime_partitioning.py
Normal file
@@ -0,0 +1,67 @@
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from hatchet_sdk.utils.datetimes import partition_date_range
|
||||
|
||||
|
||||
def test_partition_date_ranges_single_day() -> None:
|
||||
since = datetime(2025, 1, 1, 1, 2, 3, tzinfo=timezone.utc)
|
||||
until = datetime(2025, 1, 1, 3, 14, 15, tzinfo=timezone.utc)
|
||||
partitioned = partition_date_range(
|
||||
since,
|
||||
until,
|
||||
)
|
||||
|
||||
assert len(partitioned) == 1
|
||||
assert partitioned[0] == (since, until)
|
||||
|
||||
|
||||
def test_partition_date_ranges_multi_day() -> None:
|
||||
since = datetime(2025, 1, 1, 1, 2, 3, tzinfo=timezone.utc)
|
||||
until = datetime(2025, 1, 4, 3, 14, 15, tzinfo=timezone.utc)
|
||||
partitioned = partition_date_range(
|
||||
since,
|
||||
until,
|
||||
)
|
||||
|
||||
assert len(partitioned) == 4
|
||||
assert partitioned[0] == (
|
||||
since,
|
||||
datetime(2025, 1, 2, tzinfo=timezone.utc),
|
||||
)
|
||||
assert partitioned[1] == (
|
||||
datetime(2025, 1, 2, tzinfo=timezone.utc),
|
||||
datetime(2025, 1, 3, tzinfo=timezone.utc),
|
||||
)
|
||||
assert partitioned[2] == (
|
||||
datetime(2025, 1, 3, tzinfo=timezone.utc),
|
||||
datetime(2025, 1, 4, tzinfo=timezone.utc),
|
||||
)
|
||||
assert partitioned[3] == (
|
||||
datetime(2025, 1, 4, tzinfo=timezone.utc),
|
||||
until,
|
||||
)
|
||||
|
||||
|
||||
def test_partition_date_ranges_non_utc() -> None:
|
||||
since = datetime(2025, 1, 1, 22, 2, 3, tzinfo=ZoneInfo("America/New_York"))
|
||||
until = datetime(2025, 1, 4, 3, 14, 15, tzinfo=timezone.utc)
|
||||
|
||||
partitioned = partition_date_range(
|
||||
since,
|
||||
until,
|
||||
)
|
||||
|
||||
assert len(partitioned) == 3
|
||||
assert partitioned[0] == (
|
||||
since.astimezone(timezone.utc),
|
||||
datetime(2025, 1, 3, tzinfo=timezone.utc),
|
||||
)
|
||||
assert partitioned[1] == (
|
||||
datetime(2025, 1, 3, tzinfo=timezone.utc),
|
||||
datetime(2025, 1, 4, tzinfo=timezone.utc),
|
||||
)
|
||||
assert partitioned[2] == (
|
||||
datetime(2025, 1, 4, tzinfo=timezone.utc),
|
||||
until,
|
||||
)
|
||||
Reference in New Issue
Block a user