Skip to content

Commit

Permalink
[#233] Revert tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmursa-dev committed Dec 19, 2024
1 parent a68e402 commit 89c652d
Showing 1 changed file with 133 additions and 0 deletions.
133 changes: 133 additions & 0 deletions src/openklant/components/klantinteracties/api/tests/test_partijen.py
Original file line number Diff line number Diff line change
Expand Up @@ -2022,6 +2022,139 @@ def test_destroy_partij_identificator(self):
data = response.json()
self.assertEqual(data["count"], 0)

def test_invalid_choice_partij_identificator_code_register(self):
url = reverse("klantinteracties:partijidentificator-list")
partij = PartijFactory.create()
data = {
"identificeerdePartij": {"uuid": str(partij.uuid)},
"anderePartijIdentificator": "anderePartijIdentificator",
"partijIdentificator": {
"codeObjecttype": "natuurlijk_persoon",
"codeSoortObjectId": "bsn",
"objectId": "123456789",
"codeRegister": "test",
},
}
response = self.client.post(url, data)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response.data["code"], "invalid")
self.assertEqual(response.data["title"], "Invalid input.")
self.assertEqual(
response.data["invalid_params"][0]["name"],
"partijIdentificator.codeRegister",
)
self.assertEqual(response.data["invalid_params"][0]["code"], "invalid_choice")
self.assertEqual(
response.data["invalid_params"][0]["reason"],
'"test" is een ongeldige keuze.',
)

def test_invalid_choice_partij_identificator_code_objecttype(self):
url = reverse("klantinteracties:partijidentificator-list")
partij = PartijFactory.create()
data = {
"identificeerdePartij": {"uuid": str(partij.uuid)},
"anderePartijIdentificator": "anderePartijIdentificator",
"partijIdentificator": {
"codeObjecttype": "test",
"codeSoortObjectId": "bsn",
"objectId": "123456789",
"codeRegister": "brp",
},
}
response = self.client.post(url, data)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response.data["code"], "invalid")
self.assertEqual(response.data["title"], "Invalid input.")
self.assertEqual(
response.data["invalid_params"][0]["name"],
"partijIdentificator.codeObjecttype",
)
self.assertEqual(response.data["invalid_params"][0]["code"], "invalid_choice")
self.assertEqual(
response.data["invalid_params"][0]["reason"],
'"test" is een ongeldige keuze.',
)

def test_invalid_choice_partij_identificator_code_soort_object_id(self):
url = reverse("klantinteracties:partijidentificator-list")
partij = PartijFactory.create()
data = {
"identificeerdePartij": {"uuid": str(partij.uuid)},
"anderePartijIdentificator": "anderePartijIdentificator",
"partijIdentificator": {
"codeObjecttype": "natuurlijk_persoon",
"codeSoortObjectId": "test",
"objectId": "123456789",
"codeRegister": "brp",
},
}
response = self.client.post(url, data)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response.data["code"], "invalid")
self.assertEqual(response.data["title"], "Invalid input.")
self.assertEqual(
response.data["invalid_params"][0]["name"],
"partijIdentificator.codeSoortObjectId",
)
self.assertEqual(response.data["invalid_params"][0]["code"], "invalid_choice")
self.assertEqual(
response.data["invalid_params"][0]["reason"],
'"test" is een ongeldige keuze.',
)

def test_invalid_validation_partij_identificator_code_objecttype(self):
url = reverse("klantinteracties:partijidentificator-list")
partij = PartijFactory.create()
data = {
"identificeerdePartij": {"uuid": str(partij.uuid)},
"anderePartijIdentificator": "anderePartijIdentificator",
"partijIdentificator": {
"codeObjecttype": "niet_natuurlijk_persoon",
"codeSoortObjectId": "bsn",
"objectId": "123456789",
"codeRegister": "brp",
},
}

# ValidationError, "ObjectType keuzes zijn beperkt op basis van CodeRegister."
with self.assertRaises(ValidationError):
self.client.post(url, data)

def test_invalid_validation_partij_identificator_code_soort_object_id(self):
url = reverse("klantinteracties:partijidentificator-list")
partij = PartijFactory.create()
data = {
"identificeerdePartij": {"uuid": str(partij.uuid)},
"anderePartijIdentificator": "anderePartijIdentificator",
"partijIdentificator": {
"codeObjecttype": "natuurlijk_persoon",
"codeSoortObjectId": "kvk_nummer",
"objectId": "123456789",
"codeRegister": "brp",
},
}
# "CodeSoortObjectId keuzes zijn beperkt op basis van CodeObjectType.",
with self.assertRaises(ValidationError):
self.client.post(url, data)

def test_invalid_validation_partij_identificator_object_id(self):
url = reverse("klantinteracties:partijidentificator-list")
partij = PartijFactory.create()
data = {
"identificeerdePartij": {"uuid": str(partij.uuid)},
"anderePartijIdentificator": "anderePartijIdentificator",
"partijIdentificator": {
"codeObjecttype": "natuurlijk_persoon",
"codeSoortObjectId": "bsn",
"objectId": "12",
"codeRegister": "brp",
},
}
# "De lengte van de ObjectId moet tussen 8 en 9 liggen."
with self.assertRaises(ValidationError):
self.client.post(url, data)

def test_valid_validation_partij_identificator(self):
# All validations pass
url = reverse("klantinteracties:partijidentificator-list")
Expand Down

0 comments on commit 89c652d

Please sign in to comment.