Skip to content

Commit

Permalink
✅ [#2251] Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SilviaAmAm committed Nov 23, 2022
1 parent cee2243 commit a8e9e04
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
14 changes: 13 additions & 1 deletion src/openforms/forms/tests/variables/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_user_defined_variables_cast_initial_value(self):
FormVariableDataTypes.float: [None, "", 1.4],
FormVariableDataTypes.datetime: [
"",
"Invalid date",
"Invalid datetime",
"2022-09-05",
"2022-09-08T00:00:00+02:00",
],
Expand All @@ -122,6 +122,12 @@ def test_user_defined_variables_cast_initial_value(self):
"11:30:00",
"2022-09-08T11:30:00+02:00",
],
FormVariableDataTypes.date: [
"",
"Invalid date",
"2022-09-05",
"2022-09-08T00:00:00+02:00",
],
}

expected_values = {
Expand Down Expand Up @@ -149,6 +155,12 @@ def test_user_defined_variables_cast_initial_value(self):
"11:30:00",
"2022-09-08T11:30:00+02:00",
],
FormVariableDataTypes.date: [
"",
"",
"2022-09-05",
"2022-09-08T00:00:00+02:00",
],
}

for data_type, data_type_label in FormVariableDataTypes.choices:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def test_dynamic_date_component_config_based_on_variables(self):
submission=submission,
key="userDefinedDate",
form_variable__user_defined=True,
form_variable__data_type=FormVariableDataTypes.datetime,
form_variable__data_type=FormVariableDataTypes.date,
value="2022-12-31",
)
endpoint = reverse(
Expand Down
6 changes: 3 additions & 3 deletions src/openforms/submissions/tests/test_variables/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def test_to_python(self):
with self.subTest("date 1"):
date_var1 = SubmissionValueVariableFactory.create(
form_variable__user_defined=True,
form_variable__data_type=FormVariableDataTypes.datetime,
form_variable__data_type=FormVariableDataTypes.date,
value="2022-09-13",
)

Expand All @@ -167,7 +167,7 @@ def test_to_python(self):
# -> fall back to stored value
self.assertEqual(date_value2, "2022-09-13")

with self.subTest("date 3"):
with self.subTest("datetime 1"):
date_var3 = SubmissionValueVariableFactory.create(
form_variable__user_defined=True,
form_variable__data_type=FormVariableDataTypes.datetime,
Expand All @@ -182,7 +182,7 @@ def test_to_python(self):
expected = timezone.make_aware(datetime(2022, 9, 13, 11, 10, 45))
self.assertEqual(date_value3, expected)

with self.subTest("date 4 (naive datetime)"):
with self.subTest("datetime 2 (naive datetime)"):
date_var3 = SubmissionValueVariableFactory.create(
form_variable__user_defined=True,
form_variable__data_type=FormVariableDataTypes.datetime,
Expand Down

0 comments on commit a8e9e04

Please sign in to comment.