File: test_inspect.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 (27 lines) | stat: -rw-r--r-- 940 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
24
25
26
27
from beanie.odm.models import InspectionStatuses
from tests.odm.models import DocumentTestModel, DocumentTestModelFailInspection


async def test_inspect_ok(documents):
    await documents(10, "smth")
    result = await DocumentTestModel.inspect_collection()
    assert result.status == InspectionStatuses.OK
    assert result.errors == []


async def test_inspect_fail(documents):
    await documents(10, "smth")
    result = await DocumentTestModelFailInspection.inspect_collection()
    assert result.status == InspectionStatuses.FAIL
    assert len(result.errors) == 10
    assert (
        "1 validation error for DocumentTestModelFailInspection"
        in result.errors[0].error
    )


async def test_inspect_ok_with_session(documents, session):
    await documents(10, "smth")
    result = await DocumentTestModel.inspect_collection(session=session)
    assert result.status == InspectionStatuses.OK
    assert result.errors == []