Using the F filter on a not existing data key. All hosts will be returned by the filter.
def test_eq__on_not_existing_key(self, nornir):
f = F(not_existing__eq="test")
filtered = sorted(list((nornir.inventory.filter(f).hosts.keys())))
> assert filtered == []
E AssertionError: assert ['dev1.group_1',\n 'dev2.group_1',\n 'dev3.group_2',\n 'dev4.group_2',\n 'dev5.no_group',\n 'dev6.group_3'] == []
E Left contains 6 more items, first extra item: 'dev1.group_1'
E Full diff:
E [
E - ,
E + 'dev1.group_1',
E + 'dev2.group_1',
E + 'dev3.group_2',
E + 'dev4.group_2',
E + 'dev5.no_group',
E + 'dev6.group_3',
E ]
The issue was the dict object, returning a NotIplemented comparing a "string" with a dict
My teammate @zwiy discovered the following issue:
Using the F filter on a not existing data key. All hosts will be returned by the filter.
The issue was the dict object, returning a NotIplemented comparing a "string" with a dict