Ejemplo n.º 1
0
class IgnoreIP(unittest.TestCase):
    def setUp(self):
        """Call before every test case."""
        self.__filter = Filter(None)

    def tearDown(self):
        """Call after every test case."""

    def testIgnoreIPOK(self):
        ipList = "127.0.0.1", "192.168.0.1", "255.255.255.255", "99.99.99.99"
        for ip in ipList:
            self.__filter.addIgnoreIP(ip)
            self.assertTrue(self.__filter.inIgnoreIPList(ip))

        self.__filter.addIgnoreIP("www.epfl.ch")
        self.assertTrue(self.__filter.inIgnoreIPList("128.178.50.12"))

    def testIgnoreIPNOK(self):
        ipList = "", "999.999.999.999", "abcdef", "192.168.0."
        for ip in ipList:
            self.__filter.addIgnoreIP(ip)
            self.assertFalse(self.__filter.inIgnoreIPList(ip))

        self.__filter.addIgnoreIP("www.epfl.ch")
        self.assertFalse(self.__filter.inIgnoreIPList("127.177.50.10"))