Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
a880b30
draft regex base function
lvrfrc87 Dec 16, 2021
4b5ba64
Merge branch 'main' into lvrfrc87
lvrfrc87 Dec 23, 2021
e0ecb7f
fix file import
lvrfrc87 Dec 23, 2021
5dc7a12
draft regex implementation
lvrfrc87 Jan 11, 2022
5d44d36
Merge branch 'main' into lvrfrc87
lvrfrc87 Jan 11, 2022
83028d2
fix logic into regex result
lvrfrc87 Jan 11, 2022
63fcac7
remove assertion
lvrfrc87 Jan 11, 2022
e26ee77
draft test for range check type
lvrfrc87 Jan 12, 2022
0b4fc11
add match/no-match logic
lvrfrc87 Jan 13, 2022
ed1ea8a
Merge branch 'lvrfrc87' into lvrfrc_2
lvrfrc87 Jan 13, 2022
a49773d
commit save
lvrfrc87 Jan 13, 2022
79ff35e
add assertion for check option
lvrfrc87 Jan 13, 2022
862063b
add assertions for range type
lvrfrc87 Jan 14, 2022
841aac9
add assertion for strings
lvrfrc87 Jan 14, 2022
3eb0bcc
commit save
lvrfrc87 Jan 24, 2022
8438cca
Merge branch 'lvrfrc_2' into lvrfrc87
lvrfrc87 Feb 7, 2022
48c5f99
Merge branch 'main' into lvrfrc87
lvrfrc87 Feb 7, 2022
8012165
Merge branch 'main' into lvrfrc87
lvrfrc87 Feb 10, 2022
fbfe920
draft operator check type
lvrfrc87 Feb 10, 2022
84c545c
complete validate method for check_type operator
lvrfrc87 Feb 21, 2022
abbb498
work on oeprator_evaluator method
lvrfrc87 Feb 22, 2022
e054323
drat operator all-same
lvrfrc87 Feb 23, 2022
0e01f34
add all-same operator
lvrfrc87 Feb 24, 2022
cb7e507
add contains operator
lvrfrc87 Feb 25, 2022
03005ec
add not-contains. Update contains logic
lvrfrc87 Feb 28, 2022
18bcf75
add is-gt and is-lt operators
lvrfrc87 Feb 28, 2022
16cb326
add range operators
lvrfrc87 Feb 28, 2022
1c8e939
add operator lib for DRY code
lvrfrc87 Mar 2, 2022
3cbef97
fix some lint errors
lvrfrc87 Mar 2, 2022
4c2ddc0
Update netcompare/operator.py
lvrfrc87 Mar 3, 2022
45e0655
work on comments
lvrfrc87 Mar 3, 2022
ec809c2
Merge branch 'lvrfrc87' of github.com:networktocode-llc/netcompare in…
lvrfrc87 Mar 3, 2022
7e93aaa
Merge branch 'main' into lvrfrc87
lvrfrc87 Mar 3, 2022
fa4a34f
working on operator args
lvrfrc87 Mar 3, 2022
82b72ef
fix tests
lvrfrc87 Mar 3, 2022
eba9972
improve validator switch logic
lvrfrc87 Mar 4, 2022
158d16b
fix pytests
lvrfrc87 Mar 4, 2022
5311854
tolerance validate tests
lvrfrc87 Mar 7, 2022
9d3fd11
add validate parameter test
lvrfrc87 Mar 7, 2022
3eecb34
add mode to param match check type
lvrfrc87 Mar 7, 2022
7829b32
add regex validate tests
lvrfrc87 Mar 7, 2022
f8af8d3
working on operator validato tests
lvrfrc87 Mar 8, 2022
5cc0382
complete validate tests for operator
lvrfrc87 Mar 8, 2022
c933a72
Merge branch 'main' into lvrfrc87
lvrfrc87 Mar 8, 2022
1fdea99
paramet tests
lvrfrc87 Mar 9, 2022
ea94bd3
Update as per comments
lvrfrc87 Mar 10, 2022
30eacc3
fix as in comment PR
lvrfrc87 Mar 10, 2022
b90c6d6
up to JMSPATH
lvrfrc87 Mar 17, 2022
c95162f
assert data type for exclude list
lvrfrc87 Mar 18, 2022
475532b
update Readme up to exact-match
lvrfrc87 Mar 18, 2022
0466843
stash commit
lvrfrc87 Mar 22, 2022
cb98aa2
propose fix ofr issue 44
lvrfrc87 Mar 22, 2022
fc02e7b
using flatten list utils
lvrfrc87 Mar 22, 2022
b724db2
add test with index in result
lvrfrc87 Mar 22, 2022
7b2ce40
Merge branch 'fix_44' into lvrfrc87
lvrfrc87 Mar 23, 2022
3f73a39
work on readme.md
lvrfrc87 Mar 23, 2022
e09ed39
work on readme
lvrfrc87 Mar 23, 2022
9d57bf4
readne up to tolerance
lvrfrc87 Mar 23, 2022
88ba82e
up to regex
lvrfrc87 Mar 23, 2022
3a33cbd
work on operator
lvrfrc87 Mar 23, 2022
702f081
remove test for issue 45
lvrfrc87 Mar 23, 2022
b79281f
complete Readme
lvrfrc87 Mar 24, 2022
d2052e2
restor inner bool return for operator
lvrfrc87 Mar 24, 2022
0e4f807
Update README.md
lvrfrc87 Mar 24, 2022
6d69505
Update README.md
lvrfrc87 Mar 24, 2022
53843a2
Update README.md
lvrfrc87 Mar 24, 2022
bbabb62
Update README.md
lvrfrc87 Mar 24, 2022
24cb603
Update README.md
lvrfrc87 Mar 24, 2022
88972de
Update README.md
lvrfrc87 Mar 24, 2022
5e70177
Update README.md
lvrfrc87 Mar 24, 2022
1b3fab2
Update README.md
lvrfrc87 Mar 24, 2022
ffef1e4
Update README.md
lvrfrc87 Mar 24, 2022
68e5b9f
Update README.md
lvrfrc87 Mar 24, 2022
90d1275
Update README.md
lvrfrc87 Mar 24, 2022
9bc93fe
Update README.md
lvrfrc87 Mar 24, 2022
c66d28b
Update README.md
lvrfrc87 Mar 24, 2022
1c458e9
Update README.md
lvrfrc87 Mar 24, 2022
0a51089
Update README.md
lvrfrc87 Mar 24, 2022
a0bc045
Update README.md
lvrfrc87 Mar 24, 2022
ec7a32b
Update README.md
lvrfrc87 Mar 24, 2022
59b3be7
Update README.md
lvrfrc87 Mar 24, 2022
7c90ab5
Update README.md
lvrfrc87 Mar 24, 2022
332b47e
Update README.md
lvrfrc87 Mar 24, 2022
1ea17df
Update README.md
lvrfrc87 Mar 24, 2022
9c8320c
Update README.md
lvrfrc87 Mar 24, 2022
9856915
improve reference key validation
lvrfrc87 Mar 25, 2022
1791e07
Merge branch 'main' into lvrfrc87
lvrfrc87 Mar 28, 2022
3df9600
pointing CI to PyPi dev
lvrfrc87 Mar 30, 2022
1fdd01f
Merge branch 'main' into lvrfrc87
lvrfrc87 Mar 30, 2022
be016d1
Merge branch 'develop' into lvrfrc87
lvrfrc87 Apr 13, 2022
f78849a
remove inner boolean from operator
lvrfrc87 Apr 20, 2022
f454d5b
fix tests
lvrfrc87 Apr 20, 2022
19334cc
implementation fixes as per comments
lvrfrc87 Apr 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions netcompare/check_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ def validate(**kwargs) -> None:
def evaluate(self, value_to_compare: Any, params: Any) -> Tuple[Mapping, bool]:
"""Operator evaluator implementation."""
self.validate(**params)
# For naming consistency
# For name consistency.
reference_data = params
evaluation_result = operator_evaluator(reference_data["params"], value_to_compare)
return evaluation_result, not evaluation_result
return operator_evaluator(reference_data["params"], value_to_compare)
12 changes: 6 additions & 6 deletions netcompare/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def _loop_through_wrapper(self, call_ops: str) -> Tuple[bool, List]:
elif ops[call_ops](evaluated_value, self.referance_data):
result.append(item)
if result:
return (True, result)
return (False, result)
return (result, True)
return (result, False)

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

if self.referance_data and not all(result):
return (False, self.value_to_compare)
return (self.value_to_compare, False)
if self.referance_data:
return (True, self.value_to_compare)
return (self.value_to_compare, True)
if not all(result):
return (True, self.value_to_compare)
return (False, self.value_to_compare)
return (self.value_to_compare, True)
return (self.value_to_compare, False)

def contains(self) -> Tuple[bool, List]:
"""Contains operator implementation."""
Expand Down
182 changes: 79 additions & 103 deletions tests/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,36 @@
{"params": {"mode": "all-same", "operator_data": True}},
"result[0].vrfs.default.peerList[*].[$peerAddress$,peerGroup,vrf,state]",
(
(
False,
[
{
"7.7.7.7": {
"peerGroup": "EVPN-OVERLAY-SPINE",
"state": "Idle",
"vrf": "default",
}
},
{
"10.1.0.0": {
"peerGroup": "IPv4-UNDERLAY-SPINE",
"state": "Idle",
"vrf": "default",
}
},
{
"10.2.0.0": {
"peerGroup": "IPv4-UNDERLAY-SPINE",
"state": "Idle",
"vrf": "default",
}
},
{
"10.64.207.255": {
"peerGroup": "IPv4-UNDERLAY-MLAG-PEER",
"state": "Idle",
"vrf": "default",
}
},
],
),
[
{
"7.7.7.7": {
"peerGroup": "EVPN-OVERLAY-SPINE",
"state": "Idle",
"vrf": "default",
}
},
{
"10.1.0.0": {
"peerGroup": "IPv4-UNDERLAY-SPINE",
"state": "Idle",
"vrf": "default",
}
},
{
"10.2.0.0": {
"peerGroup": "IPv4-UNDERLAY-SPINE",
"state": "Idle",
"vrf": "default",
}
},
{
"10.64.207.255": {
"peerGroup": "IPv4-UNDERLAY-MLAG-PEER",
"state": "Idle",
"vrf": "default",
}
},
],
False,
),
)
Expand All @@ -50,23 +47,20 @@
"operator",
{"params": {"mode": "contains", "operator_data": "EVPN"}},
"result[0].vrfs.default.peerList[*].[$peerAddress$,peerGroup]",
((True, [{"7.7.7.7": {"peerGroup": "EVPN-OVERLAY-SPINE"}}]), False),
([{"7.7.7.7": {"peerGroup": "EVPN-OVERLAY-SPINE"}}], True),
)
operator_not_contains = (
"pre.json",
"operator",
{"params": {"mode": "not-contains", "operator_data": "EVPN"}},
"result[0].vrfs.default.peerList[*].[$peerAddress$,peerGroup]",
(
(
True,
[
{"10.1.0.0": {"peerGroup": "IPv4-UNDERLAY-SPINE"}},
{"10.2.0.0": {"peerGroup": "IPv4-UNDERLAY-SPINE"}},
{"10.64.207.255": {"peerGroup": "IPv4-UNDERLAY-MLAG-PEER"}},
],
),
False,
[
{"10.1.0.0": {"peerGroup": "IPv4-UNDERLAY-SPINE"}},
{"10.2.0.0": {"peerGroup": "IPv4-UNDERLAY-SPINE"}},
{"10.64.207.255": {"peerGroup": "IPv4-UNDERLAY-MLAG-PEER"}},
],
True,
),
)
operator_is_gt = (
Expand All @@ -75,16 +69,13 @@
{"params": {"mode": "is-gt", "operator_data": 20}},
"result[0].vrfs.default.peerList[*].[$peerAddress$,prefixesSent]",
(
(
True,
[
{"7.7.7.7": {"prefixesSent": 50}},
{"10.1.0.0": {"prefixesSent": 50}},
{"10.2.0.0": {"prefixesSent": 50}},
{"10.64.207.255": {"prefixesSent": 50}},
],
),
False,
[
{"7.7.7.7": {"prefixesSent": 50}},
{"10.1.0.0": {"prefixesSent": 50}},
{"10.2.0.0": {"prefixesSent": 50}},
{"10.64.207.255": {"prefixesSent": 50}},
],
True,
),
)
operator_is_lt = (
Expand All @@ -93,16 +84,13 @@
{"params": {"mode": "is-lt", "operator_data": 60}},
"result[0].vrfs.default.peerList[*].[$peerAddress$,prefixesSent]",
(
(
True,
[
{"7.7.7.7": {"prefixesSent": 50}},
{"10.1.0.0": {"prefixesSent": 50}},
{"10.2.0.0": {"prefixesSent": 50}},
{"10.64.207.255": {"prefixesSent": 50}},
],
),
False,
[
{"7.7.7.7": {"prefixesSent": 50}},
{"10.1.0.0": {"prefixesSent": 50}},
{"10.2.0.0": {"prefixesSent": 50}},
{"10.64.207.255": {"prefixesSent": 50}},
],
True,
),
)
operator_is_in = (
Expand All @@ -111,16 +99,13 @@
{"params": {"mode": "is-in", "operator_data": [20, 40, 50]}},
"result[0].vrfs.default.peerList[*].[$peerAddress$,prefixesSent]",
(
(
True,
[
{"7.7.7.7": {"prefixesSent": 50}},
{"10.1.0.0": {"prefixesSent": 50}},
{"10.2.0.0": {"prefixesSent": 50}},
{"10.64.207.255": {"prefixesSent": 50}},
],
),
False,
[
{"7.7.7.7": {"prefixesSent": 50}},
{"10.1.0.0": {"prefixesSent": 50}},
{"10.2.0.0": {"prefixesSent": 50}},
{"10.64.207.255": {"prefixesSent": 50}},
],
True,
),
)
operator_not_in = (
Expand All @@ -129,16 +114,13 @@
{"params": {"mode": "not-in", "operator_data": [20, 40, 60]}},
"result[0].vrfs.default.peerList[*].[$peerAddress$,prefixesSent]",
(
(
True,
[
{"7.7.7.7": {"prefixesSent": 50}},
{"10.1.0.0": {"prefixesSent": 50}},
{"10.2.0.0": {"prefixesSent": 50}},
{"10.64.207.255": {"prefixesSent": 50}},
],
),
False,
[
{"7.7.7.7": {"prefixesSent": 50}},
{"10.1.0.0": {"prefixesSent": 50}},
{"10.2.0.0": {"prefixesSent": 50}},
{"10.64.207.255": {"prefixesSent": 50}},
],
True,
),
)
operator_in_range = (
Expand All @@ -147,16 +129,13 @@
{"params": {"mode": "in-range", "operator_data": (20, 60)}},
"result[0].vrfs.default.peerList[*].[$peerAddress$,prefixesSent]",
(
(
True,
[
{"7.7.7.7": {"prefixesSent": 50}},
{"10.1.0.0": {"prefixesSent": 50}},
{"10.2.0.0": {"prefixesSent": 50}},
{"10.64.207.255": {"prefixesSent": 50}},
],
),
False,
[
{"7.7.7.7": {"prefixesSent": 50}},
{"10.1.0.0": {"prefixesSent": 50}},
{"10.2.0.0": {"prefixesSent": 50}},
{"10.64.207.255": {"prefixesSent": 50}},
],
True,
),
)
operator_not_in_range = (
Expand All @@ -165,16 +144,13 @@
{"params": {"mode": "not-range", "operator_data": (20, 40)}},
"result[0].vrfs.default.peerList[*].[$peerAddress$,prefixesSent]",
(
(
True,
[
{"7.7.7.7": {"prefixesSent": 50}},
{"10.1.0.0": {"prefixesSent": 50}},
{"10.2.0.0": {"prefixesSent": 50}},
{"10.64.207.255": {"prefixesSent": 50}},
],
),
False,
[
{"7.7.7.7": {"prefixesSent": 50}},
{"10.1.0.0": {"prefixesSent": 50}},
{"10.2.0.0": {"prefixesSent": 50}},
{"10.64.207.255": {"prefixesSent": 50}},
],
True,
),
)

Expand Down