File: test_delete.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 (53 lines) | stat: -rw-r--r-- 1,684 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from tests.odm.models import DocumentTestModel


async def test_delete_one(documents):
    await documents(4, "uno")
    await documents(2, "dos")
    await documents(1, "cuatro")
    await DocumentTestModel.find_one({"test_str": "uno"}).delete()
    documents = await DocumentTestModel.find_all().to_list()
    assert len(documents) == 6


async def test_delete_one_not_found(documents):
    await documents(4, "uno")
    await documents(2, "dos")
    await documents(1, "cuatro")
    await DocumentTestModel.find_one({"test_str": "wrong"}).delete()
    documents = await DocumentTestModel.find_all().to_list()
    assert len(documents) == 7


async def test_delete_many(documents):
    await documents(4, "uno")
    await documents(2, "dos")
    await documents(1, "cuatro")
    await DocumentTestModel.find_many({"test_str": "uno"}).delete()
    documents = await DocumentTestModel.find_all().to_list()
    assert len(documents) == 3


async def test_delete_many_not_found(documents):
    await documents(4, "uno")
    await documents(2, "dos")
    await documents(1, "cuatro")
    await DocumentTestModel.find_many({"test_str": "wrong"}).delete()
    documents = await DocumentTestModel.find_all().to_list()
    assert len(documents) == 7


async def test_delete_all(documents):
    await documents(4, "uno")
    await documents(2, "dos")
    await documents(1, "cuatro")
    await DocumentTestModel.delete_all()
    documents = await DocumentTestModel.find_all().to_list()
    assert len(documents) == 0


async def test_delete(document):
    doc_id = document.id
    await document.delete()
    new_document = await DocumentTestModel.get(doc_id)
    assert new_document is None