| 1 |
""" |
| 2 |
test_phone_util |
| 3 |
~~~~~~~~~~~~~~~ |
| 4 |
|
| 5 |
Tests for PhoneUtil class in flask_security.phone_util. |
| 6 |
Covers phone number validation and canonicalization logic. |
| 7 |
""" |
| 8 |
|
| 9 |
import pytest |
| 10 |
from flask_security.phone_util import PhoneUtil |
| 11 |
|
| 12 |
|
| 13 |
# Use default app fixture from conftest.py |
| 14 |
# Override config using the recommended settings marker |
| 15 |
@pytest.mark.settings(phone_region_default="US") |
| 16 |
@pytest.mark.parametrize( |
| 17 |
"input_number", ["123456", "bad-number-%%%", "+999", "abcdefgh"] |
| 18 |
) |
| 19 |
def test_invalid_phone_numbers_return_none(app, input_number): |
| 20 |
with app.app_context(): |
| 21 |
phone_util = PhoneUtil(app) |
| 22 |
assert phone_util.get_canonical_form(input_number) is None |