|
10 | 10 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
11 | 11 | # for more details. |
12 | 12 |
|
| 13 | +from unittest.mock import Mock |
13 | 14 | from pyafipws.wsaa import WSAA |
14 | 15 | from pyafipws.wsfev1 import WSFEv1, main |
15 | 16 | from builtins import str |
|
39 | 40 |
|
40 | 41 | pytestmark =[pytest.mark.vcr, pytest.mark.freeze_time('2021-07-01')] |
41 | 42 |
|
42 | | - |
43 | 43 | def test_dummy(auth): |
44 | 44 | wsfev1 = auth |
45 | 45 | wsfev1.Dummy() |
@@ -222,6 +222,60 @@ def test_reproceso_nota_debito(auth): |
222 | 222 | test_autorizar_comprobante(auth, tipo_cbte, cbte_nro, servicios=False) |
223 | 223 | assert (wsfev1.Reproceso == "S") |
224 | 224 |
|
| 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 |
225 | 279 |
|
226 | 280 | def test_main(auth): |
227 | 281 | sys.argv = [] |
|
0 commit comments