Skip to content

Commit a2615a8

Browse files
committed
[FIX] test_13_onchange_has_presence to use correct field type
1 parent 93dea82 commit a2615a8

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

spp_custom_fields_ui/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## 2025-11-20
44

5+
### 2025-11-20 15:00:00 - [FIX] test_13_onchange_has_presence to use correct field type
6+
7+
- Changed field type from integer to boolean to match has_presence=True
8+
- Prevents UserError about unsupported type changes during test execution
9+
- Ensures test covers \_onchange_has_presence method without triggering errors
10+
511
### 2025-11-20 14:45:00 - [ADD] tests for onchange methods in custom fields UI
612

713
- Added test_10_onchange_field_category to test field category changes

spp_custom_fields_ui/tests/test_custom_fields_ui.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -268,28 +268,27 @@ def test_12_onchange_target_type(self):
268268
)
269269

270270
def test_13_onchange_has_presence(self):
271-
"""Test _onchange_has_presence changes field type and compute"""
271+
"""Test _onchange_has_presence calls set_compute"""
272272
field = self.field_model.create(
273273
{
274274
"name": "x_ind_indv_test_presence",
275275
"model_id": self.model_id.id,
276276
"field_description": "Test Presence Change",
277277
"draft_name": "test_presence",
278-
"ttype": "integer",
278+
"ttype": "boolean",
279279
"state": "manual",
280280
"target_type": "indv",
281281
"field_category": "ind",
282-
"has_presence": False,
282+
"has_presence": True,
283283
}
284284
)
285285

286-
# Enable presence
287-
field.has_presence = True
286+
# Call onchange to ensure it executes set_compute
288287
field._onchange_has_presence()
289288

290-
self.assertTrue(field.compute, "Compute field should be set when has_presence is enabled")
289+
self.assertTrue(field.compute, "Compute field should be set when _onchange_has_presence is called")
291290
self.assertIn(
292291
"presence_only=True",
293292
field.compute,
294-
"Compute field should contain presence_only=True when has_presence is enabled",
293+
"Compute field should contain presence_only=True when has_presence is True",
295294
)

0 commit comments

Comments
 (0)