Skip to content

Commit

Permalink
[ADD] l10n_ar_edi_ux: Add test_update_from_afip
Browse files Browse the repository at this point in the history
  • Loading branch information
mem-adhoc authored and zaoral committed Sep 25, 2024
1 parent 66c7453 commit 3ebee59
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions l10n_ar_edi_ux/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
##############################################################################
from . import models
from . import wizards
from . import tests
from .monkey_patches import *
1 change: 1 addition & 0 deletions l10n_ar_edi_ux/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_update_from_afip
63 changes: 63 additions & 0 deletions l10n_ar_edi_ux/tests/test_update_from_afip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import odoo.tests.common as common
from odoo.exceptions import UserError


class TestUpdateFromAfip(common.TransactionCase):

def testmonotributo(self):
"""Actualizamos un contacto del tipo monotributo"""

# Chequeamos que no hay actividades ni impuestos creados
self.assertEqual(self.env['afip.activity'], self.env['afip.activity'].search([]), "Activities are not being created.")
self.assertEqual(self.env['afip.tax'], self.env['afip.tax'].search([]), "Taxes are not being created.")

contacto = self.env['res.partner'].create({
'name': 'Partner Monotributo',
'vat': '20221064233',
'l10n_latam_identification_type_id': self.env.ref('l10n_ar.it_cuit').id,
})
res_id = contacto.button_update_partner_data_from_afip()['res_id']
wiz = self.env['res.partner.update.from.padron.wizard'].browse(res_id)
wiz.update_selection()

self.assertEqual(contacto.name, 'Marjorier, Lamara', "Name after the update from afip must change")

# Chequeamos que las actividades e impuestos se hayan creado con la actualizacion
self.assertTrue(contacto.actividad_monotributo_padron, "Actividad monotributo padron are not being created.")
self.assertTrue(contacto.actividades_padron, "Activities are not being created.")
self.assertTrue(contacto.impuestos_padron, "Taxes are not being created.")

def testresponsableinscripto(self):
"""Actualizamos un contacto del tipo Responsable Inscripto"""

# Chequeamos que no hay actividades ni impuestos creados
self.assertEqual(self.env['afip.activity'], self.env['afip.activity'].search([]), "Activities are not being created.")
self.assertEqual(self.env['afip.tax'], self.env['afip.tax'].search([]), "Taxes are not being created.")

contacto = self.env['res.partner'].create({
'name': 'Partner Responsable Inscripto',
'vat': '20188027963',
'l10n_latam_identification_type_id': self.env.ref('l10n_ar.it_cuit').id,
})
res_id = contacto.button_update_partner_data_from_afip()['res_id']
wiz = self.env['res.partner.update.from.padron.wizard'].browse(res_id)
wiz.update_selection()

self.assertEqual(contacto.name, 'Paniagua Koler, Venancio', "Name after the update from afip must change")

# Chequeamos que las actividades e impuestos se hayan creado con la actualizacion
self.assertTrue(contacto.actividades_padron, "Activities are not being created.")
self.assertTrue(contacto.impuestos_padron, "Taxes are not being created.")

def testcontactoerror(self):
"""Aseguramos de catchear bien el error del contacto"""

contacto = self.env['res.partner'].create({
'name': 'Partner Error',
'vat': '30999999995',
'l10n_latam_identification_type_id': self.env.ref('l10n_ar.it_cuit').id,
})
error_message = 'El número de documento informado es inválido'
with self.assertRaisesRegex(UserError, error_message):
contacto.button_update_partner_data_from_afip()
self.assertTrue(error_message not in contacto.message_ids.mapped('body'), "Not message should be posted in the contact if there was an error")

0 comments on commit 3ebee59

Please sign in to comment.