Skip to content

Commit 485bb49

Browse files
committed
updating tests
1 parent 209c419 commit 485bb49

File tree

5 files changed

+30
-138
lines changed

5 files changed

+30
-138
lines changed

splitio/api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class APIUriException(APIException):
1919

2020
def __init__(self, custom_message, status_code=None):
2121
"""Constructor."""
22-
APIException.__init__(self, custom_message)
22+
APIException.__init__(self, custom_message, status_code)
2323

2424
def headers_from_metadata(sdk_metadata, client_key=None):
2525
"""

tests/integration/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
split11 = {"splits": [{"trafficTypeName": "user", "name": "SPLIT_2","trafficAllocation": 100,"trafficAllocationSeed": 1057590779, "seed": -113875324, "status": "ACTIVE","killed": False, "defaultTreatment": "off", "changeNumber": 1675443569027,"algo": 2, "configurations": {},"conditions": [{"conditionType": "ROLLOUT","matcherGroup": {"combiner": "AND","matchers": [{"keySelector": { "trafficType": "user", "attribute": None },"matcherType": "ALL_KEYS","negate": False,"userDefinedSegmentMatcherData": None,"whitelistMatcherData": None,"unaryNumericMatcherData": None,"betweenMatcherData": None,"booleanMatcherData": None,"dependencyMatcherData": None,"stringMatcherData": None}]},"partitions": [{ "treatment": "on", "size": 100 },{ "treatment": "off", "size": 0 }],"label": "default rule"}]},{"trafficTypeName": "user", "name": "SPLIT_1", "trafficAllocation": 100, "trafficAllocationSeed": -1780071202,"seed": -1442762199, "status": "ACTIVE","killed": False, "defaultTreatment": "off", "changeNumber": 1675443537882,"algo": 2, "configurations": {},"conditions": [{"conditionType": "ROLLOUT", "matcherGroup": {"combiner": "AND","matchers": [{"keySelector": { "trafficType": "user", "attribute": None },"matcherType": "ALL_KEYS","negate": False,"userDefinedSegmentMatcherData": None,"whitelistMatcherData": None,"unaryNumericMatcherData": None,"betweenMatcherData": None,"booleanMatcherData": None,"dependencyMatcherData": None,"stringMatcherData": None}]},"partitions": [{ "treatment": "on", "size": 0 },{ "treatment": "off", "size": 100 }],"label": "default rule"}]}],"since": -1,"till": 1675443569027}
1+
split11 = {"splits": [{"trafficTypeName": "user", "name": "SPLIT_2","trafficAllocation": 100,"trafficAllocationSeed": 1057590779, "seed": -113875324, "status": "ACTIVE","killed": False, "defaultTreatment": "off", "changeNumber": 1675443569027,"algo": 2, "configurations": {},"conditions": [{"conditionType": "ROLLOUT","matcherGroup": {"combiner": "AND","matchers": [{"keySelector": { "trafficType": "user", "attribute": None },"matcherType": "ALL_KEYS","negate": False,"userDefinedSegmentMatcherData": None,"whitelistMatcherData": None,"unaryNumericMatcherData": None,"betweenMatcherData": None,"booleanMatcherData": None,"dependencyMatcherData": None,"stringMatcherData": None}]},"partitions": [{ "treatment": "on", "size": 100 },{ "treatment": "off", "size": 0 }],"label": "default rule"}], "sets": ["set_1"]},{"trafficTypeName": "user", "name": "SPLIT_1", "trafficAllocation": 100, "trafficAllocationSeed": -1780071202,"seed": -1442762199, "status": "ACTIVE","killed": False, "defaultTreatment": "off", "changeNumber": 1675443537882,"algo": 2, "configurations": {},"conditions": [{"conditionType": "ROLLOUT", "matcherGroup": {"combiner": "AND","matchers": [{"keySelector": { "trafficType": "user", "attribute": None },"matcherType": "ALL_KEYS","negate": False,"userDefinedSegmentMatcherData": None,"whitelistMatcherData": None,"unaryNumericMatcherData": None,"betweenMatcherData": None,"booleanMatcherData": None,"dependencyMatcherData": None,"stringMatcherData": None}]},"partitions": [{ "treatment": "on", "size": 0 },{ "treatment": "off", "size": 100 }],"label": "default rule"}], "sets": ["set_1", "set_2"]}],"since": -1,"till": 1675443569027}
22
split12 = {"splits": [{"trafficTypeName": "user","name": "SPLIT_2","trafficAllocation": 100,"trafficAllocationSeed": 1057590779,"seed": -113875324,"status": "ACTIVE","killed": True,"defaultTreatment": "off","changeNumber": 1675443767288,"algo": 2,"configurations": {},"conditions": [{"conditionType": "ROLLOUT","matcherGroup": {"combiner": "AND","matchers": [{"keySelector": { "trafficType": "user", "attribute": None },"matcherType": "ALL_KEYS","negate": False,"userDefinedSegmentMatcherData": None,"whitelistMatcherData": None,"unaryNumericMatcherData": None,"betweenMatcherData": None,"booleanMatcherData": None,"dependencyMatcherData": None,"stringMatcherData": None}]},"partitions": [{ "treatment": "on", "size": 100 },{ "treatment": "off", "size": 0 }],"label": "default rule"}]}],"since": 1675443569027,"till": 167544376728}
33
split13 = {"splits": [{"trafficTypeName": "user","name": "SPLIT_1","trafficAllocation": 100,"trafficAllocationSeed": -1780071202,"seed": -1442762199,"status": "ARCHIVED","killed": False,"defaultTreatment": "off","changeNumber": 1675443984594,"algo": 2,"configurations": {},"conditions": [{"conditionType": "ROLLOUT","matcherGroup": {"combiner": "AND","matchers": [{"keySelector": { "trafficType": "user", "attribute": None },"matcherType": "ALL_KEYS","negate": False,"userDefinedSegmentMatcherData": None,"whitelistMatcherData": None,"unaryNumericMatcherData": None,"betweenMatcherData": None,"booleanMatcherData": None,"dependencyMatcherData": None,"stringMatcherData": None}]},"partitions": [{ "treatment": "on", "size": 0 },{ "treatment": "off", "size": 100 }],"label": "default rule"}]},{"trafficTypeName": "user","name": "SPLIT_2","trafficAllocation": 100,"trafficAllocationSeed": 1057590779,"seed": -113875324,"status": "ACTIVE","killed": False,"defaultTreatment": "off","changeNumber": 1675443954220,"algo": 2,"configurations": {},"conditions": [{"conditionType": "ROLLOUT","matcherGroup": {"combiner": "AND","matchers": [{"keySelector": { "trafficType": "user", "attribute": None },"matcherType": "ALL_KEYS","negate": False,"userDefinedSegmentMatcherData": None,"whitelistMatcherData": None,"unaryNumericMatcherData": None,"betweenMatcherData": None,"booleanMatcherData": None,"dependencyMatcherData": None,"stringMatcherData": None}]},"partitions": [{ "treatment": "on", "size": 100 },{ "treatment": "off", "size": 0 }],"label": "default rule"}]}],"since": 1675443767288,"till": 1675443984594}
44

tests/integration/files/splitChanges.json

Lines changed: 14 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
}
5959
]
6060
}
61-
]
61+
],
62+
"sets": ["set1", "set2"]
6263
},
6364
{
6465
"orgId": null,
@@ -95,7 +96,8 @@
9596
}
9697
]
9798
}
98-
]
99+
],
100+
"sets": ["set4"]
99101
},
100102
{
101103
"orgId": null,
@@ -136,7 +138,8 @@
136138
}
137139
]
138140
}
139-
]
141+
],
142+
"sets": ["set3"]
140143
},
141144
{
142145
"orgId": null,
@@ -198,31 +201,9 @@
198201
"size": 70
199202
}
200203
]
201-
},
202-
{
203-
"matcherGroup": {
204-
"combiner": "AND",
205-
"matchers": [
206-
{
207-
"matcherType": "ALL_KEYS",
208-
"negate": false,
209-
"userDefinedSegmentMatcherData": null,
210-
"whitelistMatcherData": null
211-
}
212-
]
213-
},
214-
"partitions": [
215-
{
216-
"treatment": "on",
217-
"size": 0
218-
},
219-
{
220-
"treatment": "off",
221-
"size": 100
222-
}
223-
]
224204
}
225-
]
205+
],
206+
"sets": ["set1"]
226207
},
227208
{
228209
"orgId": null,
@@ -261,31 +242,9 @@
261242
"size": 100
262243
}
263244
]
264-
},
265-
{
266-
"matcherGroup": {
267-
"combiner": "AND",
268-
"matchers": [
269-
{
270-
"matcherType": "ALL_KEYS",
271-
"negate": false,
272-
"userDefinedSegmentMatcherData": null,
273-
"whitelistMatcherData": null
274-
}
275-
]
276-
},
277-
"partitions": [
278-
{
279-
"treatment": "on",
280-
"size": 0
281-
},
282-
{
283-
"treatment": "off",
284-
"size": 100
285-
}
286-
]
287245
}
288-
]
246+
],
247+
"sets": []
289248
},
290249
{
291250
"orgId": null,
@@ -321,31 +280,9 @@
321280
"size": 0
322281
}
323282
]
324-
},
325-
{
326-
"matcherGroup": {
327-
"combiner": "AND",
328-
"matchers": [
329-
{
330-
"matcherType": "ALL_KEYS",
331-
"negate": false,
332-
"userDefinedSegmentMatcherData": null,
333-
"whitelistMatcherData": null
334-
}
335-
]
336-
},
337-
"partitions": [
338-
{
339-
"treatment": "on",
340-
"size": 0
341-
},
342-
{
343-
"treatment": "off",
344-
"size": 100
345-
}
346-
]
347283
}
348-
]
284+
],
285+
"sets": []
349286
},
350287
{
351288
"orgId": null,
@@ -381,31 +318,9 @@
381318
"size": 0
382319
}
383320
]
384-
},
385-
{
386-
"matcherGroup": {
387-
"combiner": "AND",
388-
"matchers": [
389-
{
390-
"matcherType": "ALL_KEYS",
391-
"negate": false,
392-
"userDefinedSegmentMatcherData": null,
393-
"whitelistMatcherData": null
394-
}
395-
]
396-
},
397-
"partitions": [
398-
{
399-
"treatment": "on",
400-
"size": 0
401-
},
402-
{
403-
"treatment": "off",
404-
"size": 100
405-
}
406-
]
407321
}
408-
]
322+
],
323+
"sets": []
409324
}
410325
],
411326
"since": -1,

tests/integration/files/split_changes.json

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
}
5959
]
6060
}
61-
]
61+
],
62+
"sets": ["set1", "set2"]
6263
},
6364
{
6465
"orgId": null,
@@ -95,7 +96,8 @@
9596
}
9697
]
9798
}
98-
]
99+
],
100+
"sets": ["set4"]
99101
},
100102
{
101103
"orgId": null,
@@ -136,7 +138,8 @@
136138
}
137139
]
138140
}
139-
]
141+
],
142+
"sets": ["set3"]
140143
},
141144
{
142145
"orgId": null,
@@ -198,31 +201,9 @@
198201
"size": 70
199202
}
200203
]
201-
},
202-
{
203-
"matcherGroup": {
204-
"combiner": "AND",
205-
"matchers": [
206-
{
207-
"matcherType": "ALL_KEYS",
208-
"negate": false,
209-
"userDefinedSegmentMatcherData": null,
210-
"whitelistMatcherData": null
211-
}
212-
]
213-
},
214-
"partitions": [
215-
{
216-
"treatment": "on",
217-
"size": 0
218-
},
219-
{
220-
"treatment": "off",
221-
"size": 100
222-
}
223-
]
224204
}
225-
]
205+
],
206+
"sets": ["set1"]
226207
},
227208
{
228209
"orgId": null,
@@ -262,7 +243,8 @@
262243
}
263244
]
264245
}
265-
]
246+
],
247+
"sets": []
266248
},
267249
{
268250
"orgId": null,
@@ -299,7 +281,8 @@
299281
}
300282
]
301283
}
302-
]
284+
],
285+
"sets": []
303286
},
304287
{
305288
"orgId": null,
@@ -336,7 +319,8 @@
336319
}
337320
]
338321
}
339-
]
322+
],
323+
"sets": []
340324
}
341325
],
342326
"since": -1,

tests/sync/test_synchronizer.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,8 @@ def run(x, c):
9797
split_synchronizers = SplitSynchronizers(split_sync, mocker.Mock(), mocker.Mock(),
9898
mocker.Mock(), mocker.Mock())
9999
synchronizer = Synchronizer(split_synchronizers, mocker.Mock(spec=SplitTasks))
100-
assert synchronizer._LOGGER.name == 'splitio.sync.synchronizer'
101100

102101
synchronizer.synchronize_splits(None)
103-
104102
synchronizer.sync_all(3)
105103
assert synchronizer._backoff._attempt == 0
106104

@@ -414,7 +412,6 @@ async def get_change_number():
414412
split_synchronizers = SplitSynchronizers(split_sync, mocker.Mock(), mocker.Mock(),
415413
mocker.Mock(), mocker.Mock())
416414
sychronizer = SynchronizerAsync(split_synchronizers, mocker.Mock(spec=SplitTasks))
417-
assert sychronizer._LOGGER.name == 'asyncio'
418415

419416
await sychronizer.synchronize_splits(None) # APIExceptions are handled locally and should not be propagated!
420417

@@ -689,7 +686,6 @@ def test_start_periodic_data_recording(self, mocker):
689686
clear_filter_task
690687
)
691688
synchronizer = RedisSynchronizer(mocker.Mock(spec=SplitSynchronizers), split_tasks)
692-
assert synchronizer._LOGGER.name == 'splitio.sync.synchronizer'
693689
synchronizer.start_periodic_data_recording()
694690

695691
assert len(impression_count_task.start.mock_calls) == 1
@@ -764,7 +760,6 @@ async def test_start_periodic_data_recording(self, mocker):
764760
clear_filter_task
765761
)
766762
synchronizer = RedisSynchronizerAsync(mocker.Mock(spec=SplitSynchronizers), split_tasks)
767-
assert synchronizer._LOGGER.name == 'asyncio'
768763
synchronizer.start_periodic_data_recording()
769764

770765
assert len(impression_count_task.start.mock_calls) == 1
@@ -1018,7 +1013,6 @@ def test_synchronize_splits(self, mocker):
10181013
segment_sync = LocalSegmentSynchronizer(mocker.Mock(), mocker.Mock(), mocker.Mock())
10191014
synchronizers = SplitSynchronizers(split_sync, segment_sync, None, None, None)
10201015
local_synchronizer = LocalhostSynchronizer(synchronizers, mocker.Mock(), mocker.Mock())
1021-
assert local_synchronizer._LOGGER.name == 'splitio.sync.synchronizer'
10221016

10231017
def synchronize_splits(*args, **kwargs):
10241018
return ["segmentA", "segmentB"]
@@ -1077,7 +1071,6 @@ async def test_synchronize_splits(self, mocker):
10771071
segment_sync = LocalSegmentSynchronizerAsync(mocker.Mock(), mocker.Mock(), mocker.Mock())
10781072
synchronizers = SplitSynchronizers(split_sync, segment_sync, None, None, None)
10791073
local_synchronizer = LocalhostSynchronizerAsync(synchronizers, mocker.Mock(), mocker.Mock())
1080-
assert local_synchronizer._LOGGER.name == 'asyncio'
10811074

10821075
self.called = False
10831076
async def synchronize_segments(*args):

0 commit comments

Comments
 (0)