belfastbuild-backend / backend /tests /test_postcodes.py
pritamdeka
commit
21f359b
Raw
History Blame Contribute Delete
750 Bytes
"""Postcode regex tests — spec section 6.1 case 2."""
from __future__ import annotations
import pytest
from app.postcodes import is_ni_postcode
@pytest.mark.parametrize(
"value",
[
"BT1 5GS",
"BT9 7AG",
"BT15 4ET",
"BT38 8QB",
"bt11 9aa",
],
)
def test_ni_postcodes_accepted(value: str) -> None:
assert is_ni_postcode(value)
@pytest.mark.parametrize(
"value",
[
"SW1A 1AA", # English
"EC1A 1BB", # London
"G1 1AA", # Glasgow
"M1 1AA", # Manchester
"BT", # too short
"BT999 1AB", # too high
"INVALID",
"",
],
)
def test_non_ni_postcodes_rejected(value: str) -> None:
assert not is_ni_postcode(value)