-
-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] l10n_br_base: add test units for resource pix
- Loading branch information
1 parent
f48e3b6
commit 5900857
Showing
2 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
from odoo.exceptions import ValidationError | ||
from odoo.tests import TransactionCase | ||
|
||
|
||
class ValidCreatePIXTest(TransactionCase): | ||
"""Test if ValidationError is raised well during create({})""" | ||
|
||
def setUp(self): | ||
super().setUp() | ||
self.partner_id = self.env.ref("l10n_br_base.res_partner_amd") | ||
|
||
def test_invalid_pix_cnpj_too_big(self): | ||
pix_vals = { | ||
"partner_id": self.partner_id.id, | ||
"key_type": "cnpj_cpf", | ||
"key": "0296089500013199", | ||
} | ||
self.check_validation_error_on_create(pix_vals) | ||
|
||
def test_invalid_pix_cnpj_too_less(self): | ||
pix_vals = { | ||
"partner_id": self.partner_id.id, | ||
"key_type": "cnpj_cpf", | ||
"key": "950001319", | ||
} | ||
self.check_validation_error_on_create(pix_vals) | ||
|
||
def test_invalid_pix_cnpj_wrong_value(self): | ||
pix_vals = { | ||
"partner_id": self.partner_id.id, | ||
"key_type": "cnpj_cpf", | ||
"key": "12345897560234", | ||
} | ||
self.check_validation_error_on_create(pix_vals) | ||
|
||
def test_invalid_pix_phone_wrong_value(self): | ||
pix_vals = { | ||
"partner_id": self.partner_id.id, | ||
"key_type": "phone", | ||
"key": "1103252020", | ||
} | ||
self.check_validation_error_on_create(pix_vals) | ||
|
||
def test_invalid_pix_phone_wrong_country_code(self): | ||
pix_vals = { | ||
"partner_id": self.partner_id.id, | ||
"key_type": "phone", | ||
"key": "0119991123456789", | ||
} | ||
self.check_validation_error_on_create(pix_vals) | ||
|
||
def test_invalid_pix_email_wrong_value(self): | ||
pix_vals = { | ||
"partner_id": self.partner_id.id, | ||
"key_type": "email", | ||
"key": "teste#teste.com", | ||
} | ||
self.check_validation_error_on_create(pix_vals) | ||
|
||
def test_invalid_pix_email_too_long(self): | ||
pix_vals = { | ||
"partner_id": self.partner_id.id, | ||
"key_type": "email", | ||
"key": "toooooooolooooooooooongemaaaaaailllllll@teeeeeeeee" | ||
"eeeeeeeeeeeeeeeeeeeest.com.br", | ||
} | ||
self.check_validation_error_on_create(pix_vals) | ||
|
||
def test_invalid_pix_EVP_wrong_value(self): | ||
pix_vals = { | ||
"partner_id": self.partner_id.id, | ||
"key_type": "evp", | ||
"key": "nmmnaasa-qwhjwqhjk-2112", | ||
} | ||
self.check_validation_error_on_create(pix_vals) | ||
|
||
def test_invalid_pix_EVP_wrong_blocks(self): | ||
pix_vals = { | ||
"partner_id": self.partner_id.id, | ||
"key_type": "evp", | ||
"key": "123e4567-e12b-12d1-a456-426655-40000", | ||
} | ||
self.check_validation_error_on_create(pix_vals) | ||
|
||
def test_invalid_pix_EVP_wrong_hex(self): | ||
pix_vals = { | ||
"partner_id": self.partner_id.id, | ||
"key_type": "evp", | ||
"key": "123*4567-e12b-12d1-a456-426655440000", | ||
} | ||
self.check_validation_error_on_create(pix_vals) | ||
|
||
def check_validation_error_on_create(self, pix_vals): | ||
with self.assertRaises(ValidationError): | ||
self.env["res.partner.pix"].with_context(tracking_disable=True).create( | ||
pix_vals | ||
) |