File: test_distinct.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 (28 lines) | stat: -rw-r--r-- 1,233 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
from tests.odm.models import DocumentTestModel


async def test_distinct_unique(documents, document_not_inserted):
    await documents(1, "uno")
    await documents(2, "dos")
    await documents(3, "cuatro")
    expected_result = ["cuatro", "dos", "uno"]
    unique_test_strs = await DocumentTestModel.distinct("test_str", {})
    assert unique_test_strs == expected_result
    document_not_inserted.test_str = "uno"
    await document_not_inserted.insert()
    another_unique_test_strs = await DocumentTestModel.distinct("test_str", {})
    assert another_unique_test_strs == expected_result


async def test_distinct_different_value(documents, document_not_inserted):
    await documents(1, "uno")
    await documents(2, "dos")
    await documents(3, "cuatro")
    expected_result = ["cuatro", "dos", "uno"]
    unique_test_strs = await DocumentTestModel.distinct("test_str", {})
    assert unique_test_strs == expected_result
    document_not_inserted.test_str = "diff_val"
    await document_not_inserted.insert()
    another_unique_test_strs = await DocumentTestModel.distinct("test_str", {})
    assert not another_unique_test_strs == expected_result
    assert another_unique_test_strs == ["cuatro", "diff_val", "dos", "uno"]