def test_create_one_ipset(self, sock=None): with WiSet(name=self.name, sock=sock) as myset: myset.create() list_wiset = load_all_ipsets(sock=sock) assert test_ipset_exist(self.name, sock=sock) myset.destroy() assert not test_ipset_exist(self.name, sock=sock) assert self.name in list_wiset assert self.name not in load_all_ipsets(sock=sock)
def test_create_ipset_twice(self, sock=None): with WiSet(name=self.name, sock=sock) as myset: myset.create() try: myset.create(exclusive=True) assert False except IPSetError: pass myset.create(exclusive=False) myset.destroy() assert self.name not in load_all_ipsets(sock=sock)
def test_stats_consistency(self, sock=None): """ Test several way to fill the statistics of one IPSet """ entries = ["1.2.3.4", "1.2.3.5", "1.2.3.6"] myset = WiSet(name=self.name, sock=sock) myset.create() myset.insert_list(entries) myset_lists = load_all_ipsets(sock=sock, content=True)[self.name] for value in entries: assert value in myset_lists.content myset_list = load_ipset(self.name, sock=sock, content=True) for value in entries: assert value in myset_list.content myset.destroy()