From 79bad4ce6275dfe6ba56bf2393b9f70adccd5c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Thu, 16 Nov 2023 16:06:05 +0100 Subject: [PATCH] Test phonenumber handling of phone number extensions --- tests/test_phonenumber.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_phonenumber.py b/tests/test_phonenumber.py index d0759ef7..06e438f2 100644 --- a/tests/test_phonenumber.py +++ b/tests/test_phonenumber.py @@ -18,6 +18,17 @@ def test_phonenumber_default_format(self): with override_settings(PHONENUMBER_DEFAULT_FORMAT="RFC3966"): self.assertEqual(str(phone), "tel:+33-6-12-34-56-78") + def test_phonenumber_extensions(self): + for data in [ + "+33612345678 extension 456", + "+33612345678 ext. 456", + "+33612345678,456", + ]: + with self.subTest(data): + phone = PhoneNumber.from_string(data) + self.assertEqual(phone.as_international, "+33 6 12 34 56 78 ext. 456") + self.assertEqual(phone.as_rfc3966, "tel:+33-6-12-34-56-78;ext=456") + def test_phonenumber_formatting_properties(self): phone = PhoneNumber.from_string("+33612345678") self.assertEqual(phone.as_e164, "+33612345678")