Skip to content

Commit aa7fd36

Browse files
authored
Merge pull request #138 from HanslettTheDev/fix-issue107
adding unit tests for wsfev1 based on issue #107
2 parents c2206a8 + 3a62832 commit aa7fd36

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

tests/test_wsfev1.py

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1111
# for more details.
1212

13+
from unittest.mock import Mock
1314
from pyafipws.wsaa import WSAA
1415
from pyafipws.wsfev1 import WSFEv1, main
1516
from builtins import str
@@ -39,7 +40,6 @@
3940

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

42-
4343
def test_dummy(auth):
4444
wsfev1 = auth
4545
wsfev1.Dummy()
@@ -222,6 +222,60 @@ def test_reproceso_nota_debito(auth):
222222
test_autorizar_comprobante(auth, tipo_cbte, cbte_nro, servicios=False)
223223
assert (wsfev1.Reproceso == "S")
224224

225+
def test_agregar_actividad():
226+
"""Test Agrego actividad a una factura (interna)"""
227+
wsfev1 = WSFEv1()
228+
wsfev1.CrearFactura()
229+
wsfev1.AgregarActividad(960990)
230+
assert wsfev1.factura["actividades"][0]["actividad_id"] == 960990
231+
232+
233+
def test_param_get_actividades():
234+
"""Test the response values from activity code from the web service"""
235+
def simulate_wsfev1_client():
236+
mock = Mock()
237+
238+
mock_response = {
239+
"FEParamGetActividadesResult": {
240+
"ResultGet": [
241+
{
242+
"ActividadesTipo": {
243+
"Id": 1,
244+
"Orden": 10,
245+
"Desc": "Activity 1",
246+
}
247+
},
248+
{
249+
"ActividadesTipo": {
250+
"Id": 2,
251+
"Orden": 20,
252+
"Desc": "Activity 2",
253+
}
254+
},
255+
]
256+
}
257+
}
258+
259+
mock.FEParamGetActividades.return_value = mock_response
260+
261+
return mock
262+
263+
264+
wsfev1 = WSFEv1()
265+
wsfev1.Cuit = "sdfsdf"
266+
wsfev1.client = simulate_wsfev1_client()
267+
268+
# call the ParamGetActividades where the client
269+
# will be instantiated by the mock
270+
items = wsfev1.ParamGetActividades()
271+
272+
expected_result = [
273+
"1|10|Activity 1",
274+
"2|20|Activity 2",
275+
]
276+
277+
# Check the methods return the expected result
278+
assert items == expected_result
225279

226280
def test_main(auth):
227281
sys.argv = []

0 commit comments

Comments
 (0)