Skip to content

Commit

Permalink
Add test for validate_possible_number
Browse files Browse the repository at this point in the history
  • Loading branch information
akjanik committed Dec 12, 2017
1 parent b2e2ccb commit 0623a62
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_userprofile.py
Expand Up @@ -10,9 +10,11 @@

import i18naddress
import pytest
from django.core.exceptions import ValidationError
from django.http import QueryDict

from saleor.userprofile import forms, models, i18n
from saleor.userprofile.validators import validate_possible_number

@pytest.fixture
def billing_address(db):
Expand Down Expand Up @@ -107,3 +109,18 @@ def test_country_aware_form_has_only_supported_countries():
for country in i18n.UNKNOWN_COUNTRIES:
assert country not in i18n.COUNTRY_FORMS
assert country not in country_choices


@pytest.mark.parametrize("input,exception", [
('123', ValidationError),
('+48123456789', None),
('+12025550169', None),
('+481234567890', ValidationError),
('testext', ValidationError),
])
def test_validate_possible_number(input, exception):
if exception is not None:
with pytest.raises(exception):
validate_possible_number(input)
else:
validate_possible_number(input)

0 comments on commit 0623a62

Please sign in to comment.