Skip to content

Commit

Permalink
test: find by datetime (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-right authored Dec 9, 2021
1 parent b9c2fcc commit 928fdc2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/odm/query/test_find.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,13 @@ async def test_bson_encoders_filed_types():
DocumentWithBsonEncodersFiledsTypes.color == Color("7fffd4")
)
assert c_fromdb.color.as_hex() == c.color.as_hex()


async def test_find_by_datetime(preset_documents):
datetime_1 = datetime.datetime.utcnow() - datetime.timedelta(days=7)
datetime_2 = datetime.datetime.utcnow() - datetime.timedelta(days=2)
docs = await Sample.find(
Sample.timestamp >= datetime_1,
Sample.timestamp <= datetime_2,
).to_list()
assert len(docs) == 5

0 comments on commit 928fdc2

Please sign in to comment.