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

[IMP] l10n_br_cnpj_search: add valid cnpj in tests. #3451

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
64 changes: 6 additions & 58 deletions l10n_br_cnpj_search/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def setUpClass(cls):
"socios": [
{
"tipoSocio": "2",
"cpf": "07119488449",
"cpf": "38729752000160",
"nome": "LUIZA ARAUJO DE OLIVEIRA",
"qualificacao": "49",
"dataInclusao": "2014-01-01",
Expand All @@ -78,58 +78,6 @@ def setUpClass(cls):
"qualificacao": "00",
},
},
{
"tipoSocio": "2",
"cpf": "23982012600",
"nome": "JOANA ALVES MUNDIM PENA",
"qualificacao": "49",
"dataInclusao": "2014-01-01",
"pais": {"codigo": "105", "descricao": "BRASIL"},
"representanteLegal": {
"cpf": "00000000000",
"nome": "",
"qualificacao": "00",
},
},
{
"tipoSocio": "2",
"cpf": "13946994415",
"nome": "LUIZA BARBOSA BEZERRA",
"qualificacao": "49",
"dataInclusao": "2014-01-01",
"pais": {"codigo": "105", "descricao": "BRASIL"},
"representanteLegal": {
"cpf": "00000000000",
"nome": "",
"qualificacao": "00",
},
},
{
"tipoSocio": "2",
"cpf": "00031298702",
"nome": "MARCELO ANTONIO BARROS DE CICCO",
"qualificacao": "49",
"dataInclusao": "2014-01-01",
"pais": {"codigo": "105", "descricao": "BRASIL"},
"representanteLegal": {
"cpf": "00000000000",
"nome": "",
"qualificacao": "00",
},
},
{
"tipoSocio": "2",
"cpf": "76822320300",
"nome": "LUIZA ALDENORA",
"qualificacao": "49",
"dataInclusao": "2014-01-01",
"pais": {"codigo": "105", "descricao": "BRASIL"},
"representanteLegal": {
"cpf": "00000000000",
"nome": "",
"qualificacao": "00",
},
},
],
"endereco": {
"tipoLogradouro": "SETOR",
Expand Down Expand Up @@ -163,7 +111,7 @@ def setUpClass(cls):
"socios": [
{
"tipoSocio": "2",
"cpf": "07119488449",
"cpf": "42806249000562",
"nome": "LUIZA ARAUJO DE OLIVEIRA",
"qualificacao": "49",
"dataInclusao": "2014-01-01",
Expand All @@ -176,7 +124,7 @@ def setUpClass(cls):
},
{
"tipoSocio": "2",
"cpf": "23982012600",
"cpf": "50745238000114",
"nome": "JOANA ALVES MUNDIM PENA",
"qualificacao": "49",
"dataInclusao": "2014-01-01",
Expand All @@ -189,7 +137,7 @@ def setUpClass(cls):
},
{
"tipoSocio": "2",
"cpf": "13946994415",
"cpf": "42887406000340",
"nome": "LUIZA BARBOSA BEZERRA",
"qualificacao": "49",
"dataInclusao": "2014-01-01",
Expand All @@ -202,7 +150,7 @@ def setUpClass(cls):
},
{
"tipoSocio": "2",
"cpf": "00031298702",
"cpf": "39367267000157",
"nome": "MARCELO ANTONIO BARROS DE CICCO",
"qualificacao": "49",
"dataInclusao": "2014-01-01",
Expand All @@ -215,7 +163,7 @@ def setUpClass(cls):
},
{
"tipoSocio": "2",
"cpf": "76822320300",
"cpf": "62157094000245",
"nome": "LUIZA ALDENORA",
"qualificacao": "49",
"dataInclusao": "2014-01-01",
Expand Down
25 changes: 13 additions & 12 deletions l10n_br_cnpj_search/tests/test_serpro.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def test_serpro_basica(self):

def test_serpro_not_found(self):
# In the Trial version there are only a few registered CNPJ records
self.model.search([("cnpj_cpf", "=", "44.356.113/0001-08")]).unlink()
self.set_param("serpro_schema", "basica")
invalid = self.model.create(
{"name": "invalid", "cnpj_cpf": "44.356.113/0001-08"}
)
Expand All @@ -77,7 +79,6 @@ def assert_socios(self, partner, expected_cnpjs):
[("id", "in", partner.child_ids.ids)],
fields=["name", "cnpj_cpf", "company_type"],
)

for s in socios:
s.pop("id")

Expand Down Expand Up @@ -112,13 +113,21 @@ def assert_socios(self, partner, expected_cnpjs):
self.assertEqual(socios, expected_socios)

def test_serpro_empresa(self):
self.env["ir.config_parameter"].sudo().set_param(
"l10n_br_base.allow_cnpj_multi_ie", "True"
)
expected_cnpjs = {
"Joana": "50745238000114",
"Aldenora": "62157094000245",
"Araujo": "42806249000562",
"Barbosa": "42887406000340",
"Marcelo": "39367267000157",
}
with mock.patch(
"odoo.addons.l10n_br_cnpj_search.models.cnpj_webservice.CNPJWebservice.validate",
return_value=self.mocked_response_serpro_2,
):
self.model.search([("cnpj_cpf", "=", "34.238.864/0002-49")]).write(
{"active": False}
)
self.model.search([("cnpj_cpf", "=", "34.238.864/0002-49")]).unlink()
self.set_param("serpro_schema", "empresa")

dummy_empresa = self.model.create(
Expand All @@ -135,14 +144,6 @@ def test_serpro_empresa(self):
)
wizard.action_update_partner()

expected_cnpjs = {
"Joana": "23982012600",
"Aldenora": "76822320300",
"Araujo": "07119488449",
"Barbosa": "13946994415",
"Marcelo": "00031298702",
}

self.assert_socios(dummy_empresa, expected_cnpjs)
dummy_empresa.unlink()

Expand Down
Loading