File: test_count.py

package info (click to toggle)
python-beanie 2.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,480 kB
  • sloc: python: 14,427; makefile: 7; sh: 6
file content (23 lines) | stat: -rw-r--r-- 659 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from tests.odm.models import DocumentTestModel


async def test_count(documents):
    await documents(4, "uno", True)
    c = await DocumentTestModel.count()
    assert c == 4


async def test_count_with_filter_query(documents):
    await documents(4, "uno", True)
    await documents(2, "dos", True)
    await documents(1, "cuatro", True)
    c = await DocumentTestModel.find_many({"test_str": "dos"}).count()
    assert c == 2


async def test_count_with_limit(documents):
    await documents(5, "five", True)
    c = await DocumentTestModel.find_all().limit(1).count()
    assert c == 1
    d = await DocumentTestModel.find_all().count()
    assert d == 5