-
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
6 changed files
with
80 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
"""Dashboard consent validators tests.""" | ||
|
||
import pytest | ||
from django.core.exceptions import ValidationError | ||
from django.core.exceptions import ImproperlyConfigured, ValidationError | ||
|
||
from apps.consent.validators import ( | ||
validate_company_schema, | ||
validate_control_authority_schema, | ||
validate_control_authority_schema_on_ready, | ||
validate_representative_schema, | ||
) | ||
|
||
|
@@ -237,3 +238,44 @@ def test_validate_control_authority_schema_invalid(): | |
invalid_value["additional_property"] = "" | ||
with pytest.raises(ValidationError): | ||
validate_control_authority_schema(invalid_value) | ||
|
||
|
||
def test_valid_control_authority(settings): | ||
"""Test validate_control_authority_schema_on_ready with valid data.""" | ||
|
||
# Change temporally settings.CONSENT_CONTROL_AUTHORITY. | ||
settings.CONSENT_CONTROL_AUTHORITY = { | ||
"name": "Control Authority Name", | ||
"represented_by": "John Doe", | ||
"email": "[email protected]", | ||
"address_1": "123 Street Name", | ||
"address_2": "", | ||
"zip_code": "12345", | ||
"city": "City Name", | ||
} | ||
|
||
# ImproperlyConfigured should not be raised | ||
try: | ||
validate_control_authority_schema_on_ready() | ||
except ImproperlyConfigured as e: | ||
pytest.fail(f"settings.CONSENT_CONTROL_AUTHORITY validation error: {e.message}") | ||
|
||
|
||
def test_invalid_control_authority(settings): | ||
"""Test validate_control_authority_schema_on_ready with invalid data.""" | ||
|
||
# Change temporally settings.CONSENT_CONTROL_AUTHORITY with invalid data. | ||
# invalid: the key 'name' is expected, not 'firstname' | ||
settings.CONSENT_CONTROL_AUTHORITY = { | ||
"firstname": "Control Authority Name", | ||
"represented_by": "John Doe", | ||
"email": "[email protected]", | ||
"address_1": "", | ||
"address_2": "", | ||
"zip_code": "12345", | ||
"city": "City Name", | ||
} | ||
|
||
# must raise ImproperlyConfigured | ||
with pytest.raises(ImproperlyConfigured): | ||
validate_control_authority_schema_on_ready() |
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