Skip to content

Commit

Permalink
transaction: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cybergrind committed Jul 16, 2020
1 parent 7da0997 commit 3344977
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
22 changes: 22 additions & 0 deletions aiozk/test/test_transaction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest
from aiozk.transaction import Transaction


@pytest.mark.asyncio
async def test_transaction(zk, path):
t = Transaction(zk)
t.create(path)
t.set_data(path, b'test_data')
t.delete(path)
res = await t.commit()
assert bool(res)


@pytest.mark.asyncio
async def test_fail_transaction(zk, path):
t = Transaction(zk)
t.create(path)
t.check_version(path, 1)
t.check_version(path, 0)
res = await t.commit()
assert not bool(res)
3 changes: 0 additions & 3 deletions aiozk/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,3 @@ def __bool__(self):
len(self.updated),
len(self.deleted),
]) > 0

def __nonzero__(self):
return self.__bool__()

0 comments on commit 3344977

Please sign in to comment.