Skip to content

Commit

Permalink
✅ [#4246] Add unit tests for get_identifier_value plugin method
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed Jul 2, 2024
1 parent 1e15e5b commit c292fd6
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,46 @@ def __call__(self, *args, **kwargs):
context = mock.call_args.kwargs["context"]
self.assertIsNotNone(context) # type: ignore

def test_extract_authorizee_identifier_value(self):
cases = (
# new auth context data approach
(
SubmissionFactory.create(
auth_info__is_digid_machtigen=True,
auth_info__legal_subject_identifier_value="999333666",
),
"999333666",
),
# new auth context data, but not a BSN
(
SubmissionFactory.create(
auth_info__is_eh_bewindvoering=True,
auth_info__legal_subject_identifier_value="12345678",
),
None,
),
# legacy fallback
(
SubmissionFactory.create(
auth_info__is_digid_machtigen=True,
auth_info__legal_subject_identifier_type="",
auth_info__legal_subject_identifier_value="",
auth_info__machtigen={"identifier_value": "999333666"},
auth_info__mandate_context=None,
),
"999333666",
),
)
plugin = HaalCentraalPrefill(PLUGIN_IDENTIFIER)

for submission, expected in cases:
with self.subTest(auth_context=submission.auth_info.to_auth_context_data()):
identifier_value = plugin.get_identifier_value(
submission, IdentifierRoles.authorizee
)

self.assertEqual(identifier_value, expected)


class HaalCentraalFindPersonV1Tests(HaalCentraalPluginTests, TestCase):
version = BRPVersions.v13
Expand Down
38 changes: 38 additions & 0 deletions src/openforms/prefill/contrib/stufbg/tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,44 @@ def test_prefill_values_for_gemachtigde_by_bsn(self):
self.assertEqual(values["postcode"], "1015 CJ")
self.assertEqual(values["woonplaatsNaam"], "Amsterdam")

def test_extract_authorizee_identifier_value(self):
cases = (
# new auth context data approach
(
SubmissionFactory.create(
auth_info__is_digid_machtigen=True,
auth_info__legal_subject_identifier_value="999333666",
),
"999333666",
),
# new auth context data, but not a BSN
(
SubmissionFactory.create(
auth_info__is_eh_bewindvoering=True,
auth_info__legal_subject_identifier_value="12345678",
),
None,
),
# legacy fallback
(
SubmissionFactory.create(
auth_info__is_digid_machtigen=True,
auth_info__legal_subject_identifier_type="",
auth_info__legal_subject_identifier_value="",
auth_info__machtigen={"identifier_value": "999333666"},
auth_info__mandate_context=None,
),
"999333666",
),
)
for submission, expected in cases:
with self.subTest(auth_context=submission.auth_info.to_auth_context_data()):
identifier_value = self.plugin.get_identifier_value(
submission, IdentifierRoles.authorizee
)

self.assertEqual(identifier_value, expected)


class StufBgCheckTests(TestCase):
@classmethod
Expand Down

0 comments on commit c292fd6

Please sign in to comment.