-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extracted compatibility module to work without AioModel subclassing +…
… tests
- Loading branch information
Showing
8 changed files
with
533 additions
and
455 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ authors = ["Alexey Kinev <[email protected]>", "Gorshkov Nikolay(contributor) <noga | |
readme = "README.md" | ||
packages = [ | ||
{ include = "peewee_async.py" }, | ||
{ include = "peewee_async_compat.py" }, | ||
{ include = "peewee_asyncext.py" }, | ||
] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import uuid | ||
|
||
from tests.conftest import all_dbs | ||
from tests.models import CompatTestModel | ||
|
||
|
||
@all_dbs | ||
async def test_create_select_compat_mode(manager): | ||
obj1 = await manager.create(CompatTestModel, text="Test 1") | ||
obj2 = await manager.create(CompatTestModel, text="Test 2") | ||
query = CompatTestModel.select().order_by(CompatTestModel.text) | ||
result = await manager.execute(query) | ||
assert list(result) == [obj1, obj2] | ||
|
||
|
||
@all_dbs | ||
async def test_update_compat_mode(manager): | ||
obj_draft = await manager.create(CompatTestModel, text="Draft 1") | ||
obj_draft.text = "Final result" | ||
await manager.update(obj_draft) | ||
obj = await manager.get(CompatTestModel, id=obj_draft.id) | ||
assert obj.text == "Final result" | ||
|
||
|
||
@all_dbs | ||
async def test_count_compat_mode(manager): | ||
obj = await manager.create(CompatTestModel, text="Unique title %s" % uuid.uuid4()) | ||
search = CompatTestModel.select().where(CompatTestModel.text == obj.text) | ||
count = await manager.count(search) | ||
assert count == 1 | ||
|
||
|
||
@all_dbs | ||
async def test_delete_compat_mode(manager): | ||
obj = await manager.create(CompatTestModel, text="Expired item %s" % uuid.uuid4()) | ||
search = CompatTestModel.select().where(CompatTestModel.id == obj.id) | ||
count_before = await manager.count(search) | ||
assert count_before == 1 | ||
await manager.delete(obj) | ||
count_after = await manager.count(search) | ||
assert count_after == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import asyncio | ||
|
||
import pytest | ||
|
||
from tests.conftest import all_dbs | ||
from tests.models import TestModel | ||
|
||
|