Skip to content

Commit

Permalink
Added draft test for compound select (feture not yet present for AioM…
Browse files Browse the repository at this point in the history
…odel)
  • Loading branch information
rudyryk committed May 9, 2024
1 parent 6f13bbc commit b7b1255
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions tests/aio_model/test_selecting.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import peewee
import pytest
from tests.conftest import all_dbs
from tests.models import TestModelAlpha, TestModelBeta
from tests.models import TestModel, TestModelAlpha, TestModelBeta


@all_dbs
async def test__select__w_join(manager):
async def test_select_w_join(manager):
alpha = await TestModelAlpha.aio_create(text="Test 1")
beta = await TestModelBeta.aio_create(alpha_id=alpha.id, text="text")

Expand All @@ -13,4 +15,22 @@ async def test__select__w_join(manager):
).aio_execute())[0]

assert result.id == beta.id
assert result.joined_alpha.id == alpha.id
assert result.joined_alpha.id == alpha.id


@pytest.mark.skip
@all_dbs
async def test_select_compound(manager):
obj1 = await manager.create(TestModel, text="Test 1")
obj2 = await manager.create(TestModel, text="Test 2")
query = (
TestModel.select().where(TestModel.id == obj1.id) |
TestModel.select().where(TestModel.id == obj2.id)
)
assert isinstance(query, peewee.ModelCompoundSelectQuery)
# NOTE: Two `AioModelSelect` when joining via `|` produce `ModelCompoundSelectQuery`
# without `aio_execute()` method, so only compat mode is available for now.
result = await query.aio_execute()
assert len(list(result)) == 2
assert obj1 in list(result)
assert obj2 in list(result)

0 comments on commit b7b1255

Please sign in to comment.