Skip to content

Commit

Permalink
✅ [#4810] Added form variable bulk create and update test
Browse files Browse the repository at this point in the history
  • Loading branch information
robinmolen committed Nov 19, 2024
1 parent 8c7936e commit 16bda26
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/openforms/forms/tests/variables/test_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,3 +1018,57 @@ def test_bulk_create_and_update_with_prefill_constraints(self):
"Prefill plugin, attribute and options can not be specified at the same time."
),
)

def test_bulk_create_and_update_with_non_camel_case_initial_values(self):
user = StaffUserFactory.create(user_permissions=["change_form"])
self.client.force_authenticate(user)

form = FormFactory.create()
form_step = FormStepFactory.create(form=form)
form_definition = form_step.form_definition
form_path = reverse("api:form-detail", kwargs={"uuid_or_slug": form.uuid})
form_url = f"http://testserver.com{form_path}"
form_definition_path = reverse(
"api:formdefinition-detail", kwargs={"uuid": form_definition.uuid}
)
form_definition_url = f"http://testserver.com{form_definition_path}"

data = [
{
"form": form_url,
"form_definition": form_definition_url,
"key": form_definition.configuration["components"][0]["key"],
"name": "Test",
"service_fetch_configuration": None,
"data_type": FormVariableDataTypes.object,
"source": FormVariableSources.component,
"initial_value": {
"VALUE IN UPPERCASE": True,
"VALUE-IN-UPPER-KEBAB-CASE": True,
"VALUE_IN_UPPER_SNAKE_CASE": False,
"value in lower case": False,
"value-in-lower-kebab-case": False,
"value_in_lower_snake_case": True,
},
}
]

response = self.client.put(
reverse(
"api:form-variables",
kwargs={"uuid_or_slug": form.uuid},
),
data=data,
)

expected_initial_value = {
"VALUE IN UPPERCASE": True,
"VALUE-IN-UPPER-KEBAB-CASE": True,
"VALUE_IN_UPPER_SNAKE_CASE": False,
"value in lower case": False,
"value-in-lower-kebab-case": False,
"value_in_lower_snake_case": True,
}

self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(expected_initial_value, response.json()[0]['initialValue'])

0 comments on commit 16bda26

Please sign in to comment.