Skip to content

Commit

Permalink
[#311] Create Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmursa-dev committed Jan 9, 2025
1 parent b343f08 commit 32f6164
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/openklant/utils/tests/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
validate_no_space,
validate_phone_number,
validate_postal_code,
validate_country,
)


Expand Down Expand Up @@ -147,3 +148,22 @@ def test_validate_iban(self):
self.assertIsNone(validate_iban("ab1299999999999"))
self.assertIsNone(validate_iban("ab129"))
self.assertIsNone(validate_iban("ab12aaaaaaaaaa"))

def test_validate_country(self):
invalid_codes = [
"",
"1",
"10",
"ZZ",
"1Z",
]
for code in invalid_codes:
self.assertRaisesMessage(
ValidationError,
"Ongeldige landcode, de code moet behoren tot de ISO 3166-standaard",
validate_country,
code,
)

self.assertIsNone(validate_country("NL"))
self.assertIsNone(validate_country("nl"))
2 changes: 1 addition & 1 deletion src/openklant/utils/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def validate_country(value) -> None:
"""
if not value.upper() in COUNTRIES_DICT.keys():
raise ValidationError(
_("Ongeldige landcode, de code moet behoren tot de ISO 3166-standaard.")
_("Ongeldige landcode, de code moet behoren tot de ISO 3166-standaard")
)


Expand Down

0 comments on commit 32f6164

Please sign in to comment.