Пример #1
0
def test_errors(client_mock: Client, endpoint: str,
                expected_exc: type) -> None:
    with pytest.raises(expected_exc) as exc_info:
        client_mock.put(endpoint, dict(firma='{hola}'))
    exc = exc_info.value
    assert repr(exc)
    assert str(exc)
Пример #2
0
def test_forbidden_without_vpn(orden):
    pkey_passphrase = '12345678'
    empresa = 'TAMIZI'
    client = Client(empresa=empresa,
                    priv_key=PKEY,
                    priv_key_passphrase=pkey_passphrase)
    with pytest.raises(TransportError) as exc_info:
        client.registrar_orden(orden)
    assert exc_info.value.status_code == 403
Пример #3
0
def test_account_registration() -> None:
    with patch('stpmex.client.Session') as mock_session:
        mock_session().request().json.return_value = {
            'descripcion': 'Cuenta en revisión.',
            'id': 0,
        }
        client = Client('TAMIZI', PKEY, '12345678')

        response = client.put(CUENTA_ENDPOINT, dict(firma='{hola}'))
        assert type(response) is dict
        assert response['id'] == 0
        assert response['descripcion'] == 'Cuenta en revisión.'
Пример #4
0
def test_incorrect_passphrase():
    pkey_passphrase = 'incorrect'
    empresa = 'TAMIZI'
    with pytest.raises(InvalidPassphrase):
        Client(empresa=empresa,
               priv_key=PKEY,
               priv_key_passphrase=pkey_passphrase)
Пример #5
0
def test_client():
    pkey_passphrase = '12345678'
    empresa = 'TAMIZI'
    client = Client(
        empresa=empresa,
        priv_key=PKEY,
        priv_key_passphrase=pkey_passphrase,
        demo=True,
    )
    assert client.soap_client.get_type('ns0:ordenPagoWS')
Пример #6
0
def test_incorrect_passphrase():
    with pytest.raises(InvalidPassphrase):
        Client('TAMIZI', PKEY, 'incorrect')
Пример #7
0
def test_forbidden_without_vpn(client):
    client = Client('TAMIZI', PKEY, '12345678', demo=False)
    with pytest.raises(HTTPError) as exc_info:
        client.request('get', '/application.wadl', {})
    assert exc_info.value.response.status_code == 403
Пример #8
0
def test_account_registration(client) -> None:
    client = Client('TAMIZI', PKEY, '12345678')
    response = client.put(CUENTA_ENDPOINT, dict(firma='{hola}'))
    assert response['id'] == 0
    assert response['descripcion'] == 'Cuenta en revisión.'