Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding unit tests for wsfev1 based on issue #107 #138

Merged
merged 2 commits into from
Nov 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading