File: test_consistency.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 (47 lines) | stat: -rw-r--r-- 1,738 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
from beanie.odm.operators.update.general import Set
from tests.odm.models import (
    DocumentTestModel,
    DocumentWithTimeStampToTestConsistency,
)


class TestResponseOfTheChangingOperations:
    async def test_insert(self, document_not_inserted):
        result = await document_not_inserted.insert()
        assert isinstance(result, DocumentTestModel)

    async def test_update(self, document):
        result = await document.update(Set({"test_int": 43}))
        assert isinstance(result, DocumentTestModel)

    async def test_save(self, document, document_not_inserted):
        document.test_int = 43
        result = await document.save()
        assert isinstance(result, DocumentTestModel)

        document_not_inserted.test_int = 43
        result = await document_not_inserted.save()
        assert isinstance(result, DocumentTestModel)

    async def test_save_changes(self, document):
        document.test_int = 43
        result = await document.save_changes()
        assert isinstance(result, DocumentTestModel)

    async def test_replace(self, document):
        result = await document.replace()
        assert isinstance(result, DocumentTestModel)

    async def test_set(self, document):
        result = await document.set({"test_int": 43})
        assert isinstance(result, DocumentTestModel)

    async def test_inc(self, document):
        result = await document.inc({"test_int": 1})
        assert isinstance(result, DocumentTestModel)

    async def test_current_date(self):
        document = DocumentWithTimeStampToTestConsistency()
        await document.insert()
        result = await document.current_date({"ts": True})
        assert isinstance(result, DocumentWithTimeStampToTestConsistency)