Implement temporary workaround from unasync package

This commit is contained in:
Serhii Charykov 2022-05-01 18:15:50 +03:00
parent 490fcec1a7
commit 85540c02bd
5 changed files with 73 additions and 96 deletions

View file

@ -9,6 +9,7 @@ import pytest_asyncio
from pydantic import ValidationError
from aredis_om import HashModel, Migrator, NotFoundError, RedisModelError
from tests.conftest import py_test_mark_asyncio
today = datetime.date.today()
@ -75,14 +76,14 @@ async def members(m):
yield member1, member2, member3
@pytest.mark.asyncio
@py_test_mark_asyncio
async def test_all_keys(members, m):
pks = sorted([pk async for pk in await m.Member.all_pks()])
assert len(pks) == 3
assert pks == sorted([m.pk for m in members])
@pytest.mark.asyncio
@py_test_mark_asyncio
async def test_not_found(m):
with pytest.raises(NotFoundError):
# This ID does not exist.
@ -114,7 +115,7 @@ def test_validation_passes(m):
assert member.first_name == "Andrew"
@pytest.mark.asyncio
@py_test_mark_asyncio
async def test_saves_model_and_creates_pk(m):
member = m.Member(
first_name="Andrew",
@ -144,7 +145,7 @@ def test_raises_error_with_embedded_models(m):
address: Address
@pytest.mark.asyncio
@py_test_mark_asyncio
async def test_saves_many(m):
member1 = m.Member(
first_name="Andrew",
@ -168,7 +169,7 @@ async def test_saves_many(m):
assert await m.Member.get(pk=member2.pk) == member2
@pytest.mark.asyncio
@py_test_mark_asyncio
async def test_updates_a_model(members, m):
member1, member2, member3 = members
await member1.update(last_name="Smith")