Skip to content

Commit

Permalink
test: add date filter
Browse files Browse the repository at this point in the history
  • Loading branch information
long2ice committed Oct 8, 2023
1 parent 0484cf5 commit ab488d0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/test_filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Reporter,
Team,
Tournament,
DateFields,
)
from tortoise.contrib import test
from tortoise.contrib.test.condition import NotEQ
Expand Down Expand Up @@ -182,6 +183,11 @@ async def test_filter_exact(self):
self.assertEqual(await DatetimeFields.filter(datetime__second=0).count(), 1)
self.assertEqual(await DatetimeFields.filter(datetime__microsecond=0).count(), 1)

await DateFields.create(date=datetime.date(year=2021, month=6, day=21))
self.assertEqual(await DateFields.filter(date__year=2021).count(), 0)
self.assertEqual(await DateFields.filter(date__month=6).count(), 0)
self.assertEqual(await DateFields.filter(date__day=21).count(), 0)

async def test_filter_by_aggregation_field(self):
tournament = await Tournament.create(name="0")
await Tournament.create(name="1")
Expand Down

0 comments on commit ab488d0

Please sign in to comment.