コード例 #1
0
def test_status_calls_correct_url():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/node/status',
                  json={'success': True},
                  status=200)

    client = PhantomClient('http://127.0.0.1:4002')
    client.node.status()
    assert len(responses.calls) == 1
    assert responses.calls[
        0].request.url == 'http://127.0.0.1:4002/node/status'
コード例 #2
0
def test_all_calls_correct_url_with_default_params():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/wallets',
                  json={'success': True},
                  status=200)

    client = PhantomClient('http://127.0.0.1:4002')
    client.wallets.all()
    assert len(responses.calls) == 1
    assert responses.calls[
        0].request.url == 'http://127.0.0.1:4002/wallets?limit=100'
コード例 #3
0
def test_all_unconfirmed_calls_correct_url_with_default_params():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/transactions/unconfirmed',
                  json={'success': True},
                  status=200)

    client = PhantomClient('http://127.0.0.1:4002')
    client.transactions.all_unconfirmed()
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url == (
        'http://127.0.0.1:4002/transactions/unconfirmed?limit=100')
コード例 #4
0
def test_votes_calls_correct_url_with_default_params():
    wallet_id = '12345'
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/wallets/{}/votes'.format(wallet_id),
                  json={'success': True},
                  status=200)

    client = PhantomClient('http://127.0.0.1:4002')
    client.wallets.votes(wallet_id)
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url == (
        'http://127.0.0.1:4002/wallets/12345/votes?limit=100')
コード例 #5
0
def test_get_calls_correct_url_with_ip():
    ip = '123.4.5.67'
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/peers/{}'.format(ip),
                  json={'success': True},
                  status=200)

    client = PhantomClient('http://127.0.0.1:4002')
    client.peers.get(ip)
    assert len(responses.calls) == 1
    assert responses.calls[
        0].request.url == 'http://127.0.0.1:4002/peers/123.4.5.67'
コード例 #6
0
def test_transactions_calls_correct_url_with_default_params():
    block_id = '12345'
    responses.add(
        responses.GET,
        'http://127.0.0.1:4002/blocks/{}/transactions'.format(block_id),
        json={'success': True},
        status=200)

    client = PhantomClient('http://127.0.0.1:4002')
    client.blocks.transactions(block_id)
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url == (
        'http://127.0.0.1:4002/blocks/12345/transactions?limit=100')
コード例 #7
0
def test_voter_balances_calls_correct_url_with_default_params():
    delegate_id = '12345'
    responses.add(
        responses.GET,
        'http://127.0.0.1:4002/delegates/{}/voters/balances'.format(delegate_id),
        json={'success': True},
        status=200
    )

    client = PhantomClient('http://127.0.0.1:4002')
    client.delegates.voter_balances(delegate_id)
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url == 'http://127.0.0.1:4002/delegates/12345/voters/balances'
コード例 #8
0
def test_get_calls_correct_url():
    wallet_id = '12345'
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/wallets/{}'.format(wallet_id),
                  json={'success': True},
                  status=200)

    client = PhantomClient('http://127.0.0.1:4002')
    client.wallets.get(wallet_id)

    assert len(responses.calls) == 1
    assert responses.calls[
        0].request.url == 'http://127.0.0.1:4002/wallets/12345'
コード例 #9
0
def test_all_unconfirmed_calls_correct_url_with_passed_in_params():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/transactions/unconfirmed',
                  json={'success': True},
                  status=200)

    client = PhantomClient('http://127.0.0.1:4002')
    client.transactions.all_unconfirmed(offset=5, limit=69)
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith(
        'http://127.0.0.1:4002/transactions/unconfirmed?')
    assert 'offset=5' in responses.calls[0].request.url
    assert 'limit=69' in responses.calls[0].request.url
コード例 #10
0
def test_top_calls_correct_url_with_passed_in_params():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/wallets/top',
                  json={'success': True},
                  status=200)

    client = PhantomClient('http://127.0.0.1:4002')
    client.wallets.top(page=5, limit=69)
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith(
        'http://127.0.0.1:4002/wallets/top?')
    assert 'page=5' in responses.calls[0].request.url
    assert 'limit=69' in responses.calls[0].request.url
コード例 #11
0
def test_search_calls_correct_url_with_default_params():
    responses.add(
        responses.POST,
        'http://127.0.0.1:4002/delegates/search',
        json={'success': True},
        status=200
    )

    client = PhantomClient('http://127.0.0.1:4002')
    client.delegates.search('deadlock')
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url == 'http://127.0.0.1:4002/delegates/search?limit=100'
    assert json.loads(responses.calls[0].request.body.decode()) == {'username': '******'}
コード例 #12
0
def test_votes_calls_correct_url_with_passed_in_params():
    wallet_id = '12345'
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/wallets/{}/votes'.format(wallet_id),
                  json={'success': True},
                  status=200)

    client = PhantomClient('http://127.0.0.1:4002')
    client.wallets.votes(wallet_id, page=5, limit=69)
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith(
        'http://127.0.0.1:4002/wallets/12345/votes?')
    assert 'page=5' in responses.calls[0].request.url
    assert 'limit=69' in responses.calls[0].request.url
コード例 #13
0
def test_search_calls_correct_url_with_default_params():
    responses.add(responses.POST,
                  'http://127.0.0.1:4002/transactions/search',
                  json={'success': True},
                  status=200)

    client = PhantomClient('http://127.0.0.1:4002')
    client.transactions.search({'blockId': '1337'})
    assert len(responses.calls) == 1
    assert responses.calls[
        0].request.url == 'http://127.0.0.1:4002/transactions/search?limit=100'
    assert json.loads(responses.calls[0].request.body.decode()) == {
        'blockId': '1337'
    }
コード例 #14
0
def test_all_calls_correct_url_with_additional_params():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/transactions',
                  json={'success': True},
                  status=200)

    client = PhantomClient('http://127.0.0.1:4002')
    client.transactions.all(page=5, limit=69, orderBy="timestamp.epoch")
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith(
        'http://127.0.0.1:4002/transactions?')
    assert 'page=5' in responses.calls[0].request.url
    assert 'limit=69' in responses.calls[0].request.url
    assert 'orderBy=timestamp.epoch' in responses.calls[0].request.url
コード例 #15
0
def test_search_calls_correct_url_with_passed_in_params():
    responses.add(
        responses.POST,
        'http://127.0.0.1:4002/delegates/search',
        json={'success': True},
        status=200
    )

    client = PhantomClient('http://127.0.0.1:4002')
    client.delegates.search('deadlock', page=5, limit=69)
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/delegates/search?')
    assert 'page=5' in responses.calls[0].request.url
    assert 'limit=69' in responses.calls[0].request.url
    assert json.loads(responses.calls[0].request.body.decode()) == {'username': '******'}
コード例 #16
0
def test_transactions_calls_correct_url_with_passed_in_params():
    block_id = '12345'
    responses.add(
        responses.GET,
        'http://127.0.0.1:4002/blocks/{}/transactions'.format(block_id),
        json={'success': True},
        status=200)

    client = PhantomClient('http://127.0.0.1:4002')
    client.blocks.transactions(block_id, page=5, limit=69)
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith(
        'http://127.0.0.1:4002/blocks/12345/transactions?')
    assert 'page=5' in responses.calls[0].request.url
    assert 'limit=69' in responses.calls[0].request.url
コード例 #17
0
def test_create_calls_correct_url_with_data():
    responses.add(responses.POST,
                  'http://127.0.0.1:4002/transactions',
                  json={'success': True},
                  status=200)

    client = PhantomClient('http://127.0.0.1:4002')
    client.transactions.create([{'random': 'data'}])
    assert len(responses.calls) == 1
    assert responses.calls[
        0].request.url == 'http://127.0.0.1:4002/transactions'
    assert json.loads(responses.calls[0].request.body.decode()) == {
        'transactions': [{
            'random': 'data'
        }]
    }
コード例 #18
0
def test_transactions_calls_correct_url_with_additional_params():
    wallet_id = '12345'
    responses.add(
        responses.GET,
        'http://127.0.0.1:4002/wallets/{}/transactions'.format(wallet_id),
        json={'success': True},
        status=200)

    client = PhantomClient('http://127.0.0.1:4002')
    client.wallets.transactions(wallet_id=wallet_id,
                                page=5,
                                limit=69,
                                orderBy="timestamp.epoch")
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith(
        'http://127.0.0.1:4002/wallets/12345/transactions?')
    assert 'page=5' in responses.calls[0].request.url
    assert 'limit=69' in responses.calls[0].request.url
    assert 'orderBy=timestamp.epoch' in responses.calls[0].request.url
コード例 #19
0
def test_transaction_types():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/transactions/types',
                  json={
                      'data': {
                          'TRANSFER': 0,
                          'SECOND_SIGNATURE': 1,
                          'DELEGATE_REGISTRATION': 2,
                          'VOTE': 3,
                          'MULTI_SIGNATURE': 4,
                          'IPFS': 5,
                          'TIMELOCK_TRANSFER': 6,
                          'MULTI_PAYMENT': 7,
                          'DELEGATE_RESIGNATION': 8
                      }
                  },
                  status=200)

    client = PhantomClient('http://127.0.0.1:4002')
    client.transactions.types()
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith(
        'http://127.0.0.1:4002/transactions/types')
コード例 #20
0
def test_all_calls_correct_url_with_passed_in_params():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/peers',
                  json={'success': True},
                  status=200)

    client = PhantomClient('http://127.0.0.1:4002')
    client.peers.all(os='a',
                     status='live',
                     port=1337,
                     version='2.0.0',
                     order_by='ip',
                     page=5,
                     limit=69)
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith(
        'http://127.0.0.1:4002/peers?')
    assert 'os=a' in responses.calls[0].request.url
    assert 'status=live' in responses.calls[0].request.url
    assert 'port=1337' in responses.calls[0].request.url
    assert 'version=2.0.0' in responses.calls[0].request.url
    assert 'orderBy=ip' in responses.calls[0].request.url
    assert 'page=5' in responses.calls[0].request.url
    assert 'limit=69' in responses.calls[0].request.url
コード例 #21
0
def test_transaction_fees():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/transactions/fees',
                  json={
                      'data': {
                          'dynamic': False,
                          'transfer': 10000000,
                          'secondSignature': 500000000,
                          'delegateRegistration': 2500000000,
                          'vote': 100000000,
                          'multiSignature': 500000000,
                          'ipfs': 0,
                          'timelockTransfer': 0,
                          'multiPayment': 0,
                          'delegateResignation': 0
                      }
                  },
                  status=200)

    client = PhantomClient('http://127.0.0.1:4002')
    client.transactions.fees()
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith(
        'http://127.0.0.1:4002/transactions/fees')