Skip to content

Commit a0dec58

Browse files
committed
test count method
1 parent ea171a8 commit a0dec58

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/test_find_count.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import datetime
2+
from typing import Optional
3+
4+
from pydantic import EmailStr
5+
6+
from aredis_om import Field, HashModel, Migrator
7+
8+
9+
class Customer(HashModel):
10+
first_name: str
11+
last_name: str = Field(index=True)
12+
email: EmailStr
13+
join_date: datetime.date
14+
age: int = Field(index=True)
15+
bio: Optional[str]
16+
17+
18+
andrew = Customer(
19+
first_name="Andrew",
20+
last_name="Brookins",
21+
22+
join_date=datetime.date.today(),
23+
age=38,
24+
)
25+
26+
await Migrator().run()
27+
28+
await Customer.find().delete()
29+
30+
andy = await andrew.save()
31+
32+
customers = await Customer.find(Customer.last_name == "Brookins").all()
33+
assert len(customers) == 1
34+
35+
await Migrator().run()
36+
37+
customers_count = await Customer.find().count()
38+
assert customers_count == 1
39+
40+
brookins_count = await Customer.find(Customer.last_name == "Brookins").count()
41+
assert brookins_count == 1

0 commit comments

Comments
 (0)