Skip to content

Commit a4e6e8c

Browse files
Fix config tests for holdout entity changes
- Add required fields (variations, trafficAllocation, audienceIds) to holdout test configs - Fix BaseEntity __eq__ to handle comparisons with non-entity types - Fix test assertion to check for holdout IDs in global_holdouts list - All 86 config tests passing - All 12 holdout config tests passing
1 parent 64a6d8d commit a4e6e8c

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

.claude/settings.local.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"Bash(python3 -c \"from optimizely import bucketer; print(''bucketer.py imports successfully'')\")",
1616
"Bash(python3 -m mypy optimizely/entities.py --no-error-summary)",
1717
"Bash(python3 -m unittest tests.test_decision_service_holdout)",
18-
"Bash(python3 -m unittest discover tests -p \"test_*.py\" -v)"
18+
"Bash(python3 -m unittest discover tests -p \"test_*.py\" -v)",
19+
"Bash(git add -A)",
20+
"Bash(git commit -m \"Fix config tests for holdout entity changes\n\n- Add required fields (variations, trafficAllocation, audienceIds) to holdout test configs\n- Fix BaseEntity __eq__ to handle comparisons with non-entity types\n- Fix test assertion to check for holdout IDs in global_holdouts list\n- All 86 config tests passing\n- All 12 holdout config tests passing\")"
1921
]
2022
}
2123
}

optimizely/entities.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
class BaseEntity:
2929
def __eq__(self, other: object) -> bool:
30+
if not hasattr(other, '__dict__'):
31+
return False
3032
return self.__dict__ == other.__dict__
3133

3234

tests/test_config.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1393,20 +1393,29 @@ def setUp(self):
13931393
'id': 'holdout_1',
13941394
'key': 'global_holdout',
13951395
'status': 'Running',
1396+
'variations': [],
1397+
'trafficAllocation': [],
1398+
'audienceIds': [],
13961399
'includedFlags': [],
13971400
'excludedFlags': [boolean_feature_id]
13981401
},
13991402
{
14001403
'id': 'holdout_2',
14011404
'key': 'specific_holdout',
14021405
'status': 'Running',
1406+
'variations': [],
1407+
'trafficAllocation': [],
1408+
'audienceIds': [],
14031409
'includedFlags': [multi_variate_feature_id],
14041410
'excludedFlags': []
14051411
},
14061412
{
14071413
'id': 'holdout_3',
14081414
'key': 'inactive_holdout',
14091415
'status': 'Inactive',
1416+
'variations': [],
1417+
'trafficAllocation': [],
1418+
'audienceIds': [],
14101419
'includedFlags': [boolean_feature_id],
14111420
'excludedFlags': []
14121421
}
@@ -1512,7 +1521,9 @@ def test_holdout_initialization__categorizes_holdouts_properly(self):
15121521

15131522
self.assertIn('holdout_1', self.config_with_holdouts.holdout_id_map)
15141523
self.assertIn('holdout_2', self.config_with_holdouts.holdout_id_map)
1515-
self.assertIn('holdout_1', self.config_with_holdouts.global_holdouts)
1524+
# Check if a holdout with ID 'holdout_1' exists in global_holdouts
1525+
holdout_ids_in_global = [h.id for h in self.config_with_holdouts.global_holdouts]
1526+
self.assertIn('holdout_1', holdout_ids_in_global)
15161527

15171528
# Use correct feature flag IDs
15181529
boolean_feature_id = '91111'

0 commit comments

Comments
 (0)