-
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.
fixup! ✨(dashboard) add validation and data updates for consent manag…
…ement
- Loading branch information
Showing
4 changed files
with
87 additions
and
243 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,12 +16,10 @@ | |
"trade_name": "The test company", | ||
"siret": "12345678901234", | ||
"naf": "1234A", | ||
"address": { | ||
"line_1": "1 rue Exemple", | ||
"line_2": None, | ||
"zip_code": "75000", | ||
"city": "Paris", | ||
}, | ||
"address_1": "1 rue Exemple", | ||
"address_2": None, | ||
"zip_code": "75000", | ||
"city": "Paris", | ||
} | ||
|
||
VALID_REPRESENTATIVE_DATA = { | ||
|
@@ -35,12 +33,10 @@ | |
"name": "QualiCharge", | ||
"represented_by": "John Doe", | ||
"email": "[email protected]", | ||
"address": { | ||
"line_1": "1 Rue Exemple", | ||
"line_2": None, | ||
"zip_code": "75000", | ||
"city": "Paris", | ||
}, | ||
"address_1": "1 Rue Exemple", | ||
"address_2": None, | ||
"zip_code": "75000", | ||
"city": "Paris", | ||
} | ||
|
||
|
||
|
@@ -111,38 +107,38 @@ def test_validate_compnay_naf_code_invalid(value): | |
def test_validate_zip_code_valid(value): | ||
"""Tests validation of valid zip codes does not raise an exception.""" | ||
valid_company_data = VALID_COMPANY_DATA | ||
valid_company_data["address"]["zip_code"] = value | ||
valid_company_data["zip_code"] = value | ||
assert validate_company_schema(valid_company_data) is None | ||
|
||
valid_authority_data = VALID_CONTROL_AUTHORITY_DATA | ||
valid_authority_data["address"]["zip_code"] = value | ||
valid_authority_data["zip_code"] = value | ||
assert validate_control_authority_schema(valid_authority_data) is None | ||
|
||
|
||
@pytest.mark.parametrize("value", ["123456", "12a45", "abcde", "", " ", 12345]) | ||
def test_validate_zip_code_invalid(value): | ||
"""Tests validation of invalid zip codes raise a ValidationError.""" | ||
valid_company_data = VALID_COMPANY_DATA | ||
valid_company_data["address"]["zip_code"] = value | ||
valid_company_data["zip_code"] = value | ||
with pytest.raises(ValidationError): | ||
validate_company_schema(valid_company_data) | ||
# reset with valid zip | ||
VALID_COMPANY_DATA["address"]["zip_code"] = "12345" | ||
VALID_COMPANY_DATA["zip_code"] = "12345" | ||
|
||
valid_authority_data = VALID_CONTROL_AUTHORITY_DATA | ||
valid_authority_data["address"]["zip_code"] = value | ||
valid_authority_data["zip_code"] = value | ||
with pytest.raises(ValidationError): | ||
validate_control_authority_schema(valid_authority_data) | ||
# reset with valid zip | ||
VALID_CONTROL_AUTHORITY_DATA["address"]["zip_code"] = "12345" | ||
VALID_CONTROL_AUTHORITY_DATA["zip_code"] = "12345" | ||
|
||
|
||
def test_validate_company_schema_valid(): | ||
"""Test the json schema validator with a valid company data.""" | ||
assert validate_company_schema(VALID_COMPANY_DATA) is None | ||
|
||
# valid with specific zip code | ||
VALID_COMPANY_DATA["address"]["zip_code"] = "978" | ||
VALID_COMPANY_DATA["zip_code"] = "978" | ||
assert validate_company_schema(VALID_COMPANY_DATA) is None | ||
|
||
# test with null values | ||
|
@@ -153,11 +149,9 @@ def test_validate_company_schema_valid(): | |
"trade_name": None, | ||
"siret": None, | ||
"naf": None, | ||
"address": { | ||
"line_1": None, | ||
"zip_code": None, | ||
"city": None, | ||
}, | ||
"address_1": None, | ||
"zip_code": None, | ||
"city": None, | ||
} | ||
assert validate_company_schema(valid_company_data) is None | ||
|
||
|
@@ -218,11 +212,9 @@ def test_validate_control_authority_schema_valid(): | |
"name": None, | ||
"represented_by": None, | ||
"email": None, | ||
"address": { | ||
"line_1": None, | ||
"zip_code": None, | ||
"city": None, | ||
}, | ||
"address_1": None, | ||
"zip_code": None, | ||
"city": None, | ||
} | ||
assert validate_control_authority_schema(validate_control_authority_data) is None | ||
|
||
|
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
Oops, something went wrong.