-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
109 additions
and
9 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
...orIntegrationTestCase/BRKValidatorIntegrationTestCase.test_brk_validator_integration.yaml
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,40 @@ | ||
interactions: | ||
- request: | ||
body: null | ||
headers: | ||
Accept: | ||
- '*/*' | ||
Accept-Encoding: | ||
- gzip, deflate, br | ||
Connection: | ||
- keep-alive | ||
User-Agent: | ||
- python-requests/2.31.0 | ||
X-Api-Key: | ||
- fake_changeme_when_testing | ||
method: GET | ||
uri: https://api.brk.kadaster.nl/esd-eto-apikey/bevragen/v2/kadastraalonroerendezaken?postcode=1234AB&huisnummer=1&huisletter=A&huisnummertoevoeging=Add | ||
response: | ||
body: | ||
string: '{"_links":{"self":{"href":"/kadastraalonroerendezaken?postcode=1234AB&huisnummer=1&huisletter=A&huisnummertoevoeging=Add"}},"_embedded":{}}' | ||
headers: | ||
Api-Version: | ||
- 2.0.0 | ||
Connection: | ||
- keep-alive | ||
Content-Encoding: | ||
- gzip | ||
Content-Length: | ||
- '133' | ||
Content-Type: | ||
- application/hal+json | ||
Date: | ||
- Thu, 04 Jan 2024 16:15:08 GMT | ||
Keep-Alive: | ||
- timeout=60 | ||
Server: | ||
- Unspecified | ||
status: | ||
code: 200 | ||
message: '' | ||
version: 1 |
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,69 @@ | ||
from unittest.mock import patch | ||
|
||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from rest_framework.reverse import reverse | ||
from rest_framework.test import APITestCase | ||
|
||
from openforms.authentication.constants import AuthAttribute | ||
from openforms.submissions.tests.factories import SubmissionFactory | ||
from openforms.submissions.tests.mixins import SubmissionsMixin | ||
from openforms.utils.tests.vcr import OFVCRMixin | ||
from openforms.validations.registry import Registry | ||
|
||
from ..validators import BRKZakelijkGerechtigdeValidator | ||
from .base import TEST_FILES, BRKTestMixin | ||
|
||
|
||
class BRKValidatorIntegrationTestCase( | ||
SubmissionsMixin, OFVCRMixin, BRKTestMixin, APITestCase | ||
): | ||
VCR_TEST_FILES = TEST_FILES | ||
|
||
def setUp(self) -> None: | ||
super().setUp() | ||
register = Registry() | ||
register( | ||
"brk-zakelijk-gerechtigd", | ||
verbose_name="dummy", | ||
for_components=("addressNL",), | ||
)(BRKZakelijkGerechtigdeValidator) | ||
|
||
patcher = patch("openforms.validations.api.views.register", new=register) | ||
patcher.start() | ||
self.addCleanup(patcher.stop) | ||
|
||
def test_brk_validator_integration(self) -> None: | ||
submission = SubmissionFactory.create( | ||
form__generate_minimal_setup=True, | ||
form__authentication_backends=["demo"], | ||
form__formstep__form_definition__login_required=False, | ||
auth_info__attribute_hashed=False, | ||
auth_info__attribute=AuthAttribute.bsn, | ||
auth_info__value="12345678", | ||
auth_info__plugin="demo", | ||
) | ||
self._add_submission_to_session(submission) | ||
|
||
response = self.client.post( | ||
reverse( | ||
"api:validate-value", kwargs={"validator": "brk-zakelijk-gerechtigd"} | ||
), | ||
{ | ||
"value": { | ||
"postcode": "1234 aB", | ||
"house_number": "1", | ||
"house_letter": "A", | ||
"house_number_addition": "Add", | ||
}, | ||
"submission_uuid": str(submission.uuid), | ||
}, | ||
format="json", | ||
) | ||
|
||
expected = { | ||
"is_valid": False, | ||
"messages": [_("No property found for this address.")], | ||
} | ||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(response.data, expected) |
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