Esempio n. 1
0
 def testFilter(self):
     """Test GeoIP filtering functionality"""        
     try:
         import GeoIP
     except ImportError:
         print >> sys.stderr, "GeoIP Python package not available - skipping geoip unittest."
         return        
     
     # Check positive filter
     self.options['filter'] = 'United States'
     output = [(geocode, ip, line) for geocode, ip, line in geoip(fh=self.fh, **self.options)]
     self.assertEquals(len(output), 2, "Output size was different than expected: %s" % str(len(output)))
     
     # Check negative filter
     self.options['filter'] = 'India'
     output = [(geocode, ip, line) for geocode, ip, line in geoip(fh=self.fh, **self.options)]
     self.assertEquals(len(output), 0, "Output size was different than expected: %s" % str(len(output)))
Esempio n. 2
0
    def testGeoIP(self):
        try:
            import GeoIP
        except ImportError:
            print >> sys.stderr, "GeoIP Python package not available - skipping geoip unittest."
            return

        output = [(geocode, ip, line) for geocode, ip, line in geoip(self.options, None, self.fh)]
        self.assertEquals(len(output), 2, "Output size was different than expected: %s" % str(len(output)))
Esempio n. 3
0
    def testGeoIP(self):
        try:
            import GeoIP
        except ImportError:
            print >> sys.stderr, "GeoIP Python package not available - skipping geoip unittest."
            return

        output = [(geocode, ip, line) for geocode, ip, line in geoip(fh=self.fh, **self.options)]
        self.assertEquals(len(output), 2, "Output size was different than expected: %s" % str(len(output)))