Skip to content

Commit

Permalink
Merge pull request #138 from HanslettTheDev/fix-issue107
Browse files Browse the repository at this point in the history
adding unit tests for wsfev1 based on issue #107
  • Loading branch information
reingart authored Nov 5, 2023
2 parents c2206a8 + 3a62832 commit aa7fd36
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion tests/test_wsfev1.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.

from unittest.mock import Mock
from pyafipws.wsaa import WSAA
from pyafipws.wsfev1 import WSFEv1, main
from builtins import str
Expand Down Expand Up @@ -39,7 +40,6 @@

pytestmark =[pytest.mark.vcr, pytest.mark.freeze_time('2021-07-01')]


def test_dummy(auth):
wsfev1 = auth
wsfev1.Dummy()
Expand Down Expand Up @@ -222,6 +222,60 @@ def test_reproceso_nota_debito(auth):
test_autorizar_comprobante(auth, tipo_cbte, cbte_nro, servicios=False)
assert (wsfev1.Reproceso == "S")

def test_agregar_actividad():
"""Test Agrego actividad a una factura (interna)"""
wsfev1 = WSFEv1()
wsfev1.CrearFactura()
wsfev1.AgregarActividad(960990)
assert wsfev1.factura["actividades"][0]["actividad_id"] == 960990


def test_param_get_actividades():
"""Test the response values from activity code from the web service"""
def simulate_wsfev1_client():
mock = Mock()

mock_response = {
"FEParamGetActividadesResult": {
"ResultGet": [
{
"ActividadesTipo": {
"Id": 1,
"Orden": 10,
"Desc": "Activity 1",
}
},
{
"ActividadesTipo": {
"Id": 2,
"Orden": 20,
"Desc": "Activity 2",
}
},
]
}
}

mock.FEParamGetActividades.return_value = mock_response

return mock


wsfev1 = WSFEv1()
wsfev1.Cuit = "sdfsdf"
wsfev1.client = simulate_wsfev1_client()

# call the ParamGetActividades where the client
# will be instantiated by the mock
items = wsfev1.ParamGetActividades()

expected_result = [
"1|10|Activity 1",
"2|20|Activity 2",
]

# Check the methods return the expected result
assert items == expected_result

def test_main(auth):
sys.argv = []
Expand Down

0 comments on commit aa7fd36

Please sign in to comment.