How to use the pynubank.nubank.Nubank function in pynubank

To help you get started, we’ve selected a few pynubank examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github andreroggeri / pynubank / tests / test_nubank_client.py View on Github external
def test_nubank_request_handler_throws_exception_with_status_code_attribute():
    http_status = 400
    response = create_fake_response({}, http_status)
    client = Nubank()
    with pytest.raises(NuException) as exception_info:
        client._handle_response(response)

    assert exception_info.value.status_code == http_status
github andreroggeri / pynubank / tests / test_nubank_client.py View on Github external
def test_grapql_query_raises_exeption(monkeypatch, authentication_return):
    nubank_client = Nubank()

    response = create_fake_response({}, 401)

    monkeypatch.setattr('requests.post', MagicMock(return_value=response))
    with pytest.raises(NuException):
        nubank_client.get_account_balance()
github andreroggeri / pynubank / tests / test_nubank_client.py View on Github external
def test_get_card_statements(monkeypatch, authentication_return, events_return):
    response = create_fake_response(authentication_return)
    monkeypatch.setattr('requests.post', MagicMock(return_value=response))
    nubank_client = Nubank()

    response = create_fake_response(events_return)
    monkeypatch.setattr('requests.get', MagicMock(return_value=response))
    statements = nubank_client.get_card_statements()

    assert len(statements) == 1
    assert statements[0]['description'] == 'Shopping Iguatemi'
    assert statements[0]['category'] == 'transaction'
    assert statements[0]['amount'] == 700
    assert statements[0]['time'] == '2017-09-09T02:03:55Z'
    assert statements[0]['title'] == 'transporte'
    assert statements[0]['id'] == 'abcde-fghi-jklmn-opqrst-uvxz'
    assert statements[0]['details']['lat'] == -12.9818258
    assert statements[0]['details']['lon'] == -38.4652058
    assert statements[0]['details']['subcategory'] == 'card_present'
    assert statements[0]['href'] == 'nuapp://transaction/abcde-fghi-jklmn-opqrst-uvxz'
github andreroggeri / pynubank / tests / test_nubank_client.py View on Github external
def test_authenticate_with_qr_code_succeeds(monkeypatch, authentication_return, proxy_list_return):
    proxy_list = create_fake_response(proxy_list_return)
    monkeypatch.setattr('requests.get', MagicMock(return_value=proxy_list))
    response = create_fake_response(authentication_return)
    monkeypatch.setattr('requests.post', MagicMock(return_value=response))

    nubank_client = Nubank()
    nubank_client.authenticate_with_qr_code('12345678912', 'hunter12', 'some-uuid')

    assert nubank_client.feed_url == 'https://prod-s0-webapp-proxy.nubank.com.br/api/proxy/events_123'
    assert nubank_client.headers['Authorization'] == 'Bearer access_token_123'
github andreroggeri / pynubank / tests / test_nubank_client.py View on Github external
def test_get_qr_code():
    client = Nubank()
    uid, qr = client.get_qr_code()

    assert uid != ''
    assert isinstance(qr, QRCode)
github andreroggeri / pynubank / tests / test_nubank_client.py View on Github external
def test_get_card_feed(monkeypatch, authentication_return, events_return):
    response = create_fake_response(authentication_return)
    monkeypatch.setattr('requests.post', MagicMock(return_value=response))
    nubank_client = Nubank()

    response = create_fake_response(events_return)
    monkeypatch.setattr('requests.get', MagicMock(return_value=response))

    feed = nubank_client.get_card_feed()
    assert feed['as_of'] == '2017-09-09T06:50:22.323Z'
    assert feed['customer_id'] == 'abcde-fghi-jklmn-opqrst-uvxz'
    assert feed['_links']['updates']['href'] == 'https://prod-s0-webapp-proxy.nubank.com.br/api/proxy/updates_123'
    assert feed['_links']['next']['href'] == 'https://prod-s0-webapp-proxy.nubank.com.br/api/proxy/next_123'

    events = feed['events']
    assert len(events) == 1
    assert events[0]['description'] == 'Shopping Iguatemi'
    assert events[0]['category'] == 'transaction'
    assert events[0]['amount'] == 700
    assert events[0]['time'] == '2017-09-09T02:03:55Z'
github andreroggeri / pynubank / tests / test_nubank_client.py View on Github external
def test_get_account_statements(monkeypatch, authentication_return, account_statements_return):
    response = create_fake_response(authentication_return)
    monkeypatch.setattr('requests.post', MagicMock(return_value=response))
    nubank_client = Nubank()

    response = create_fake_response(account_statements_return)
    monkeypatch.setattr('requests.post', MagicMock(return_value=response))
    statements = nubank_client.get_account_statements()

    assert len(statements) == 4
    assert statements[2]['id'] == 'abcde-fghi-jklmn-opqrst-uvx1'
    assert statements[2]['__typename'] == 'TransferInEvent'
    assert statements[2]['title'] == 'Transferência recebida'
    assert statements[2]['detail'] == 'R$127.33'
    assert statements[2]['postDate'] == '2018-03-06'
    assert statements[2]['amount'] == 127.33

    assert statements[3]['id'] == 'abcdefgh-ijkl-mnop-qrst-uvwxyz0123'
    assert statements[3]['__typename'] == 'BarcodePaymentEvent'
    assert statements[3]['title'] == 'Pagamento efetuado'
github andreroggeri / pynubank / tests / test_nubank_client.py View on Github external
def test_nubank_request_handler_throws_exception_with_url_attribute():
    response = create_fake_response({}, 400)
    client = Nubank()
    with pytest.raises(NuException) as exception_info:
        client._handle_response(response)

    assert exception_info.value.url == response.url
github andreroggeri / pynubank / tests / test_nubank_client.py View on Github external
def test_nubank_request_handler_throws_exception_status_code_in_the_exception_message():
    http_status = 400
    response = create_fake_response({}, http_status)
    client = Nubank()
    with pytest.raises(NuException, match=fr'.*{http_status}.*'):
        client._handle_response(response)

pynubank

MIT
Latest version published 1 year ago

Package Health Score

50 / 100
Full package analysis