File: test_phone_util.py

package info (click to toggle)
flask-security 5.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,448 kB
  • sloc: python: 23,247; javascript: 204; makefile: 138
file content (22 lines) | stat: -rw-r--r-- 660 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""
test_phone_util
~~~~~~~~~~~~~~~

Tests for PhoneUtil class in flask_security.phone_util.
Covers phone number validation and canonicalization logic.
"""

import pytest
from flask_security.phone_util import PhoneUtil


# Use default app fixture from conftest.py
# Override config using the recommended settings marker
@pytest.mark.settings(phone_region_default="US")
@pytest.mark.parametrize(
    "input_number", ["123456", "bad-number-%%%", "+999", "abcdefgh"]
)
def test_invalid_phone_numbers_return_none(app, input_number):
    with app.app_context():
        phone_util = PhoneUtil(app)
        assert phone_util.get_canonical_form(input_number) is None