Exemple #1
0
async def test_loading_dict(mocked_method, method_to_test, params):
    with async_mock(mocked_method) as method:
        method.return_value = json.dumps({'testing': 'test'})
        loaded_dict = await method_to_test(*params)
        assert isinstance(loaded_dict, dict)
        assert 'testing' in loaded_dict
        assert loaded_dict['testing'] == 'test'
Exemple #2
0
async def test_dumping_dict(mocked_method, method_to_test, before_dict,
                            after_dict):
    with async_mock(mocked_method, ) as method:
        did_dict = {'blah': 'blah'}
        await method_to_test(1, *before_dict, did_dict, *after_dict)
        method.assert_called_once_with(1, *before_dict, json.dumps(did_dict),
                                       *after_dict)
async def test_unpack_message():
    with async_mock('indy.crypto.unpack_message') as method:
        method.return_value = json.dumps({
            'message': 'message',
            'recipient_verkey': 'recipient_verkey',
            'sender_verkey': 'sender_verkey'
        })

        message, recip_vk, sender_vk = \
            await crypto.unpack_message(1, b'mock_jwe_bytes')

        method.assert_called_once_with(1, b'mock_jwe_bytes')
        assert message == 'message'
        assert recip_vk == 'recipient_verkey'
        assert sender_vk == 'sender_verkey'
async def test_create_wallet():
    with async_mock('indy.wallet.create_wallet') as m:
        await wallet.create_wallet({'a': 1}, {'b': 2})
        m.assert_called_once_with('{"a": 1}', '{"b": 2}')
async def test_close_wallet():
    with async_mock('indy.wallet.close_wallet') as m:
        await wallet.close_wallet(7)
        m.assert_called_once_with(7)
async def test_pack_message():
    with async_mock('indy.crypto.pack_message') as method:
        await crypto.pack_message(1, 'test', [])
        method.assert_called_once_with(1, 'test', [], None)