Skip to content

Commit 19334cc

Browse files
committed
implementation fixes as per comments
1 parent f454d5b commit 19334cc

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

netcompare/check_types.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,5 +326,4 @@ def evaluate(self, value_to_compare: Any, params: Any) -> Tuple[Mapping, bool]:
326326
self.validate(**params)
327327
# For name consistency.
328328
reference_data = params
329-
evaluation_result = operator_evaluator(reference_data["params"], value_to_compare)
330-
return evaluation_result[1], not evaluation_result[0]
329+
return operator_evaluator(reference_data["params"], value_to_compare)

netcompare/operator.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ def _loop_through_wrapper(self, call_ops: str) -> Tuple[bool, List]:
5050
elif ops[call_ops](evaluated_value, self.referance_data):
5151
result.append(item)
5252
if result:
53-
return (True, result)
54-
return (False, result)
53+
return (result, True)
54+
return (result, False)
5555

5656
def all_same(self) -> Tuple[bool, Any]:
5757
"""All same operator implementation."""
@@ -70,12 +70,12 @@ def all_same(self) -> Tuple[bool, Any]:
7070
result.append(True)
7171

7272
if self.referance_data and not all(result):
73-
return (False, self.value_to_compare)
73+
return (self.value_to_compare, False)
7474
if self.referance_data:
75-
return (True, self.value_to_compare)
75+
return (self.value_to_compare, True)
7676
if not all(result):
77-
return (True, self.value_to_compare)
78-
return (False, self.value_to_compare)
77+
return (self.value_to_compare, True)
78+
return (self.value_to_compare, False)
7979

8080
def contains(self) -> Tuple[bool, List]:
8181
"""Contains operator implementation."""

tests/test_operators.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@
3939
}
4040
},
4141
],
42-
True,
42+
False,
4343
),
4444
)
4545
operator_contains = (
4646
"pre.json",
4747
"operator",
4848
{"params": {"mode": "contains", "operator_data": "EVPN"}},
4949
"result[0].vrfs.default.peerList[*].[$peerAddress$,peerGroup]",
50-
([{"7.7.7.7": {"peerGroup": "EVPN-OVERLAY-SPINE"}}], False),
50+
([{"7.7.7.7": {"peerGroup": "EVPN-OVERLAY-SPINE"}}], True),
5151
)
5252
operator_not_contains = (
5353
"pre.json",
@@ -60,7 +60,7 @@
6060
{"10.2.0.0": {"peerGroup": "IPv4-UNDERLAY-SPINE"}},
6161
{"10.64.207.255": {"peerGroup": "IPv4-UNDERLAY-MLAG-PEER"}},
6262
],
63-
False,
63+
True,
6464
),
6565
)
6666
operator_is_gt = (
@@ -75,7 +75,7 @@
7575
{"10.2.0.0": {"prefixesSent": 50}},
7676
{"10.64.207.255": {"prefixesSent": 50}},
7777
],
78-
False,
78+
True,
7979
),
8080
)
8181
operator_is_lt = (
@@ -90,7 +90,7 @@
9090
{"10.2.0.0": {"prefixesSent": 50}},
9191
{"10.64.207.255": {"prefixesSent": 50}},
9292
],
93-
False,
93+
True,
9494
),
9595
)
9696
operator_is_in = (
@@ -105,7 +105,7 @@
105105
{"10.2.0.0": {"prefixesSent": 50}},
106106
{"10.64.207.255": {"prefixesSent": 50}},
107107
],
108-
False,
108+
True,
109109
),
110110
)
111111
operator_not_in = (
@@ -120,7 +120,7 @@
120120
{"10.2.0.0": {"prefixesSent": 50}},
121121
{"10.64.207.255": {"prefixesSent": 50}},
122122
],
123-
False,
123+
True,
124124
),
125125
)
126126
operator_in_range = (
@@ -135,7 +135,7 @@
135135
{"10.2.0.0": {"prefixesSent": 50}},
136136
{"10.64.207.255": {"prefixesSent": 50}},
137137
],
138-
False,
138+
True,
139139
),
140140
)
141141
operator_not_in_range = (
@@ -150,7 +150,7 @@
150150
{"10.2.0.0": {"prefixesSent": 50}},
151151
{"10.64.207.255": {"prefixesSent": 50}},
152152
],
153-
False,
153+
True,
154154
),
155155
)
156156

0 commit comments

Comments
 (0)