Skip to content

Commit 395e9a6

Browse files
committed
fix coverage
1 parent 15ec795 commit 395e9a6

File tree

4 files changed

+27
-26
lines changed

4 files changed

+27
-26
lines changed

flag_engine/segments/models.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ class SegmentRuleModel(BaseModel):
2121
rules: typing.List["SegmentRuleModel"] = Field(default_factory=list)
2222
conditions: typing.List[SegmentConditionModel] = Field(default_factory=list)
2323

24-
@staticmethod
25-
def none(iterable: typing.Iterable[object]) -> bool:
26-
return not any(iterable)
27-
2824
@property
2925
def matching_function(self) -> typing.Callable[[typing.Iterable[object]], bool]:
3026
return get_matching_function(self.type)

flag_engine/segments/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ def get_matching_function(
99
return {
1010
"ANY": any,
1111
"ALL": all,
12-
"NONE": _none,
12+
"NONE": none,
1313
}[segment_type]
1414

1515

16-
def _none(iterable: typing.Iterable[object]) -> bool:
16+
def none(iterable: typing.Iterable[object]) -> bool:
1717
return not any(iterable)

tests/unit/segments/test_segments_models.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,19 @@
55
from flag_engine.segments import constants
66
from flag_engine.segments.models import SegmentRuleModel
77
from flag_engine.segments.types import RuleType
8-
from flag_engine.segments.utils import _none
9-
10-
11-
@pytest.mark.parametrize(
12-
"iterable, expected_result",
13-
(
14-
([], True),
15-
([False], True),
16-
([False, False], True),
17-
([False, True], False),
18-
([True, True], False),
19-
),
20-
)
21-
def test_segment_rule_none(
22-
iterable: typing.List[bool],
23-
expected_result: bool,
24-
) -> None:
25-
assert SegmentRuleModel.none(iterable) is expected_result
8+
from flag_engine.segments.utils import none
269

2710

2811
@pytest.mark.parametrize(
2912
"rule_type, expected_function",
3013
(
3114
(constants.ALL_RULE, all),
3215
(constants.ANY_RULE, any),
33-
(constants.NONE_RULE, _none),
16+
(constants.NONE_RULE, none),
3417
),
3518
)
3619
def test_segment_rule_matching_function(
3720
rule_type: RuleType,
3821
expected_function: typing.Callable[[typing.Iterable[object]], bool],
3922
) -> None:
40-
assert SegmentRuleModel(type=rule_type).matching_function == expected_function
23+
assert SegmentRuleModel(type=rule_type).matching_function is expected_function
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import typing
2+
3+
import pytest
4+
5+
from flag_engine.segments.utils import none
6+
7+
8+
@pytest.mark.parametrize(
9+
"iterable, expected_result",
10+
(
11+
([], True),
12+
([False], True),
13+
([False, False], True),
14+
([False, True], False),
15+
([True, True], False),
16+
),
17+
)
18+
def test_segment_rule_none(
19+
iterable: typing.List[bool],
20+
expected_result: bool,
21+
) -> None:
22+
assert none(iterable) is expected_result

0 commit comments

Comments
 (0)