Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #136 from Artemkaaas/feature/python-wallet-tests
Browse files Browse the repository at this point in the history
Implemented Wallet integration tests for python
  • Loading branch information
Vyacheslav authored Jul 27, 2017
2 parents 257495f + 17c7664 commit a614481
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 48 deletions.
17 changes: 5 additions & 12 deletions wrappers/python/tests/wallet/test_close_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,26 @@
from indy import wallet
from indy.error import ErrorCode

from ..utils import storage

import pytest
import logging

logging.basicConfig(level=logging.DEBUG)


@pytest.mark.asyncio
async def test_close_wallet_works(cleanup_storage):
wallet_name = 'wallet1'
await wallet.create_wallet('pool1', wallet_name, None, None, None)
await wallet.create_wallet('pool1', 'wallet_1', None, None, None)

wallet_handle = await wallet.open_wallet(wallet_name, None, None)
wallet_handle = await wallet.open_wallet('wallet_1', None, None)
await wallet.close_wallet(wallet_handle)

wallet_handle = await wallet.open_wallet(wallet_name, None, None)
wallet_handle = await wallet.open_wallet('wallet_1', None, None)
await wallet.close_wallet(wallet_handle)


@pytest.mark.asyncio
async def test_close_wallet_works_for_twice(cleanup_storage):
with pytest.raises(IndyError) as e:
wallet_name = 'wallet_for_twice'
await wallet.create_wallet('pool1', wallet_name, None, None, None)
await wallet.create_wallet('pool1', 'wallet_for_twice', None, None, None)

wallet_handle = await wallet.open_wallet(wallet_name, None, None)
wallet_handle = await wallet.open_wallet('wallet_for_twice', None, None)
await wallet.close_wallet(wallet_handle)
await wallet.close_wallet(wallet_handle)

Expand Down
5 changes: 0 additions & 5 deletions wrappers/python/tests/wallet/test_create_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
from indy import wallet
from indy.error import ErrorCode

from ..utils import storage

import pytest
import logging

logging.basicConfig(level=logging.DEBUG)


@pytest.mark.asyncio
Expand Down
38 changes: 14 additions & 24 deletions wrappers/python/tests/wallet/test_delete_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,45 @@
from indy import wallet
from indy.error import ErrorCode

from ..utils import storage

import pytest
import logging

logging.basicConfig(level=logging.DEBUG)


@pytest.mark.asyncio
async def test_delete_wallet_works(cleanup_storage):
wallet_name = 'wallet1'
await wallet.create_wallet('pool1', wallet_name, None, None, None)
await wallet.delete_wallet(wallet_name, None)
await wallet.create_wallet('pool1', wallet_name, None, None, None)
await wallet.create_wallet('pool1', 'wallet_1', None, None, None)
await wallet.delete_wallet('wallet_1', None)
await wallet.create_wallet('pool1', 'wallet_1', None, None, None)


@pytest.mark.asyncio
async def test_delete_wallet_works_for_closed(cleanup_storage):
wallet_name = 'wallet2'
await wallet.create_wallet('pool1', wallet_name, None, None, None)
wallet_handle = await wallet.open_wallet(wallet_name, None, None)
await wallet.create_wallet('pool1', 'wallet_1', None, None, None)
wallet_handle = await wallet.open_wallet('wallet_1', None, None)
await wallet.close_wallet(wallet_handle)
await wallet.delete_wallet(wallet_name, None)
await wallet.create_wallet('pool1', wallet_name, None, None, None)
await wallet.delete_wallet('wallet_1', None)
await wallet.create_wallet('pool1', 'wallet_1', None, None, None)


@pytest.mark.skip(reason="There is BUG in indy-sdk")
async def test_delete_wallet_works_for_opened(cleanup_storage):
with pytest.raises(IndyError) as e:
wallet_name = 'wallet_for_opened'
await wallet.create_wallet('pool1', wallet_name, None, None, None)
await wallet.open_wallet(wallet_name, None, None)
await wallet.delete_wallet(wallet_name, None)
await wallet.create_wallet('pool1', 'wallet_for_opened', None, None, None)
await wallet.open_wallet('wallet_for_opened', None, None)
await wallet.delete_wallet('wallet_for_opened', None)
assert ErrorCode.CommonIOError == e.value.error_code


@pytest.mark.asyncio
async def test_delete_wallet_works_for_twice(cleanup_storage):
with pytest.raises(IndyError) as e:
wallet_name = 'wallet_for_twice'
await wallet.create_wallet('pool1', wallet_name, None, None, None)
await wallet.delete_wallet(wallet_name, None)
await wallet.delete_wallet(wallet_name, None)
await wallet.create_wallet('pool1', 'wallet_for_twice', None, None, None)
await wallet.delete_wallet('wallet_for_twice', None)
await wallet.delete_wallet('wallet_for_twice', None)
assert ErrorCode.CommonIOError == e.value.error_code


@pytest.mark.asyncio
async def test_delete_wallet_works_for_not_created(cleanup_storage):
with pytest.raises(IndyError) as e:
wallet_name = 'wallet_not_created'
await wallet.delete_wallet(wallet_name, None)
await wallet.delete_wallet('wallet_not_created', None)
assert ErrorCode.CommonIOError == e.value.error_code
9 changes: 2 additions & 7 deletions wrappers/python/tests/wallet/test_open_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
from indy import wallet
from indy.error import ErrorCode

from ..utils import storage

import pytest
import logging

logging.basicConfig(level=logging.DEBUG)


@pytest.mark.asyncio
Expand All @@ -21,8 +16,8 @@ async def test_open_wallet_works(cleanup_storage):

@pytest.mark.asyncio
async def test_open_wallet_works_for_config(cleanup_storage):
await wallet.create_wallet('pool1', 'wallet2', None, None, None)
wallet_handle = await wallet.open_wallet('wallet2', '{"freshness_time":1000}', None)
await wallet.create_wallet('pool1', 'wallet1', None, None, None)
wallet_handle = await wallet.open_wallet('wallet1', '{"freshness_time":1000}', None)
assert wallet_handle is not None

await wallet.close_wallet(wallet_handle)
Expand Down

0 comments on commit a614481

Please sign in to comment.