-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
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,5 +1,5 @@ | ||
from litequery.core import setup | ||
|
||
|
||
__version__ = "0.0.1" | ||
__version__ = "0.1.0" | ||
__all__ = ["setup"] |
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 |
---|---|---|
|
@@ -70,3 +70,27 @@ async def test_delete_all_users(lq): | |
assert rowcount == 2 | ||
users = await lq.get_all_users() | ||
assert len(users) == 0 | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_transaction_commit(lq): | ||
async with lq.transaction(): | ||
await lq.insert_user(name="Charlie", email="[email protected]") | ||
await lq.insert_user(name="Eve", email="[email protected]") | ||
|
||
users = await lq.get_all_users() | ||
assert len(users) == 4 | ||
assert users[2].name, users[2].email == ("Charlie", "[email protected]") | ||
assert users[3].name, users[3].email == ("Eve", "[email protected]") | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_transaction_rollback(lq): | ||
with pytest.raises(Exception): | ||
async with lq.transaction(): | ||
await lq.insert_user(name="Charlie", email="[email protected]") | ||
raise Exception("Force rollback") | ||
await lq.insert_user(name="Eve", email="[email protected]") | ||
|
||
users = await lq.get_all_users() | ||
assert len(users) == 2 |