Skip to content

Commit

Permalink
test_ws_sr_padron.py
Browse files Browse the repository at this point in the history
Signed-off-by: SONIABHISHEK121 <[email protected]>
  • Loading branch information
ABHISHEKSONI121 committed Jul 14, 2024
1 parent 3748f93 commit 363fb2a
Showing 1 changed file with 71 additions and 10 deletions.
81 changes: 71 additions & 10 deletions tests/test_ws_sr_padron.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
__copyright__ = "Copyright (C) 2010-2019 Mariano Reingart"
__license__ = "GPL 3.0"

import os, sys
import os
import sys
import pytest

from pyafipws.wsaa import WSAA
Expand All @@ -35,16 +36,14 @@
PKEY = "reingart.key"
CACHE = ""

pytestmark =pytest.mark.vcr


pytestmark = pytest.mark.vcr


@pytest.mark.xfail
def test_server_status(auth):
"""Test de estado de servidores."""
# Estados de servidores respuesta no funciona afip
wspa5=auth
wspa5 = auth
wspa5.Dummy()
assert wspa5.AppServerStatus == "OK"
assert wspa5.DbServerStatus == "OK"
Expand All @@ -53,17 +52,16 @@ def test_server_status(auth):

def test_inicializar(auth):
"""Test inicializar variables de BaseWS."""
wspa5=auth
wspa5 = auth
wspa5.inicializar()
assert wspa5.tipo_doc == 0
assert wspa5.denominacion == ""
assert wspa5.actividades == []



def test_consultar(auth):
"""Test consultar."""
wspa5=auth
wspa5 = auth
# Consulta Nivel A4 afip no esta funcionando.
id_persona = "20201797064"
consulta = wspa5.Consultar(id_persona)
Expand All @@ -72,7 +70,7 @@ def test_consultar(auth):

def test_consultar_a5(auth):
"""Test consultar padron nivel A5."""
wspa5=auth
wspa5 = auth
id_persona = "20201797064"
consulta = wspa5.Consultar(id_persona)

Expand All @@ -89,7 +87,7 @@ def test_main(auth):
sys.argv = []
sys.argv.append("--debug")
sys.argv.append("--constancia")
sys.argv.append('--prueba')
sys.argv.append("--prueba")
padron = main()
assert padron.denominacion == "ERNESTO DANIEL, MARCELO NICOLAS"
assert padron.tipo_doc == 80
Expand All @@ -108,3 +106,66 @@ def test_main_csv(auth):
sys.argv.append("--csv")
main()
assert os.path.isfile("salida.csv")


@pytest.fixture
def mock_client(mocker):
client = mocker.Mock()
client.getPersona.return_value = {
"personaReturn": {
"persona": {
"idPersona": "20000000001",
"tipoPersona": "FISICA",
"tipoClave": "CUIT",
"numeroDocumento": "00000001",
"estadoClave": "ACTIVO",
"nombre": "John",
"apellido": "Doe",
"domicilio": [
{
"tipoDomicilio": "FISCAL",
"direccion": "Test Street 123",
"localidad": "Test City",
"idProvincia": "01",
"codPostal": "12345",
}
],
"impuesto": [{"idImpuesto": "30", "estado": "ACTIVO"}],
"actividad": [{"idActividad": "123456"}],
"categoria": [{"idImpuesto": "20", "estado": "ACTIVO"}],
}
}
}
return client


def test_consultar(mock_client):
ws = WSSrPadronA4()
ws.client = mock_client
ws.Sign = "test_sign"
ws.Token = "test_token"
ws.Cuit = "test_cuit"

result = ws.Consultar("20000000001")

assert result == True
assert ws.cuit == "20000000001"
assert ws.tipo_persona == "FISICA"
assert ws.tipo_doc == 80
assert ws.nro_doc == "00000001"
assert ws.estado == "ACTIVO"
assert ws.denominacion == "Doe, John"
assert ws.direccion == "Test Street 123"
assert ws.localidad == "Test City"
assert ws.provincia == ""
assert ws.cod_postal == "12345"
assert ws.domicilio == "Test Street 123 - Test City (12345) - "
assert ws.impuestos == ["30"]
assert ws.actividades == ["123456"]

mock_client.getPersona.assert_called_once_with(
sign="test_sign",
token="test_token",
cuitRepresentada="test_cuit",
idPersona="20000000001",
)

0 comments on commit 363fb2a

Please sign in to comment.