-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move validators to dedicated file. Add tests
- Loading branch information
Showing
7 changed files
with
53 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from django.core.exceptions import ValidationError | ||
from django.test import TestCase | ||
|
||
from lemarche.utils.validators import validate_naf, validate_post_code, validate_siren, validate_siret | ||
|
||
|
||
class ValidatorsTest(TestCase): | ||
def test_post_code_validator(self): | ||
validator = validate_post_code | ||
POST_CODE_OK = ["00000", "12345", "38000"] | ||
for item in POST_CODE_OK: | ||
validator(item) | ||
POST_CODE_NOT_OK = ["0", "1234"] | ||
for item in POST_CODE_NOT_OK: | ||
self.assertRaises(ValidationError, validator, item) | ||
|
||
def test_siren_validator(self): | ||
validator = validate_siren | ||
SIREN_OK = ["123123123"] | ||
for item in SIREN_OK: | ||
validator(item) | ||
SIREN_NOT_OK = ["123"] | ||
for item in SIREN_NOT_OK: | ||
self.assertRaises(ValidationError, validator, item) | ||
|
||
def test_siret_validator(self): | ||
validator = validate_siret | ||
SIRET_OK = ["12312312312345"] | ||
for item in SIRET_OK: | ||
validator(item) | ||
SIRET_NOT_OK = ["123123123"] | ||
for item in SIRET_NOT_OK: | ||
self.assertRaises(ValidationError, validator, item) | ||
|
||
def test_naf_validator(self): | ||
validator = validate_naf | ||
NAF_OK = ["1234A"] | ||
for item in NAF_OK: | ||
validator(item) | ||
NAF_NOT_OK = ["1234", "12345", "ABCDE"] | ||
for item in NAF_NOT_OK: | ||
self.assertRaises(ValidationError, validator, item) |
File renamed without changes.