Skip to content

Commit 6dcac32

Browse files
committed
Fixed matcher
1 parent 338ac89 commit 6dcac32

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

splitio/models/grammar/matchers/rule_based_segment.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,12 @@ def _match_dep_rb_segments(self, excluded_rb_segments, key, attributes, context)
6363
else:
6464
excluded_segment = context['ec'].rbs_segments.get(excluded_rb_segment.name)
6565
if key in excluded_segment.excluded.get_excluded_keys():
66-
return False
66+
return True
6767

6868
if self._match_dep_rb_segments(excluded_segment.excluded.get_excluded_segments(), key, attributes, context):
6969
return True
70+
71+
if self._match_conditions(excluded_segment.conditions, key, attributes, context):
72+
return True
7073

71-
return self._match_conditions(excluded_segment.conditions, key, attributes, context)
74+
return False

tests/engine/files/rule_base_segments2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"trafficType": "user",
2020
"attribute": "email"
2121
},
22-
"matcherType": "START_WITH",
22+
"matcherType": "STARTS_WITH",
2323
"negate": false,
2424
"whitelistMatcherData": {
2525
"whitelist": [

tests/engine/test_evaluator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def test_using_rbs_in_excluded(self):
314314
ctx = evaluation_facctory.context_for('bilal', ['some'])
315315
assert e.eval_with_context('bilal', 'bilal', 'some', {'email': 'bilal'}, ctx)['treatment'] == "on"
316316
ctx = evaluation_facctory.context_for('bilal2@split.io', ['some'])
317-
assert e.eval_with_context('bilal2@split.io', 'bilal2@split.io', 'some', {'email': 'bilal2@split.io'}, ctx)['treatment'] == "on"
317+
assert e.eval_with_context('bilal2@split.io', 'bilal2@split.io', 'some', {'email': 'bilal2@split.io'}, ctx)['treatment'] == "off"
318318

319319
@pytest.mark.asyncio
320320
async def test_evaluate_treatment_with_rbs_in_condition_async(self):
@@ -386,7 +386,7 @@ async def test_using_rbs_in_excluded_async(self):
386386
ctx = await evaluation_facctory.context_for('bilal', ['some'])
387387
assert e.eval_with_context('bilal', 'bilal', 'some', {'email': 'bilal'}, ctx)['treatment'] == "on"
388388
ctx = await evaluation_facctory.context_for('bilal2@split.io', ['some'])
389-
assert e.eval_with_context('bilal2@split.io', 'bilal2@split.io', 'some', {'email': 'bilal2@split.io'}, ctx)['treatment'] == "on"
389+
assert e.eval_with_context('bilal2@split.io', 'bilal2@split.io', 'some', {'email': 'bilal2@split.io'}, ctx)['treatment'] == "off"
390390

391391
class EvaluationDataFactoryTests(object):
392392
"""Test evaluation factory class."""

0 commit comments

Comments
 (0)