test_phonenumbers.py 802 B

123456789101112131415161718192021222324
  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. from odoo.addons.phone_validation.tools import phone_validation
  4. from odoo.exceptions import UserError
  5. from odoo.tests import tagged
  6. from odoo.tests.common import BaseCase
  7. @tagged('phone_validation')
  8. class TestPhonenumbers(BaseCase):
  9. def test_country_code_falsy(self):
  10. self.assertEqual(
  11. phone_validation.phone_format('0456998877', 'BE', '32', force_format='E164'),
  12. '+32456998877'
  13. )
  14. # no country code -> UserError, no internal traceback
  15. with self.assertRaises(UserError):
  16. self.assertEqual(
  17. phone_validation.phone_format('0456998877', None, '32', force_format='E164'),
  18. '+32456998877'
  19. )