def test_row_retrieval(self): ip_row = IP() result = ip_row.find_by_ip(CURRENTIP) result = result[0].data() result.pop("time_stamp") self.assertEqual( result, { "request": "209.203.39.143", "status": 200, "delay": "1ms", "credit": "Some of the returned data", "city": "Bothasig", "region": "Western Cape", "region_code": "WC", "region_name": "Western Cape", "area_code": "", "dma_code": "", "country_code": "ZA", "country_name": "South Africa", "in_eu": "0", "eu_vat_rate": "0", "continent_code": "AF", "continent_name": "Africa", "latitude": "-33.8604", "longitude": "18.5446", "location_accuracy_radius": "500", "timezone": "Africa/Johannesburg", "currency_code": "ZAR", "currency_symbol": "R", "currency_converter": "14.1204", }, ) self.conn.close()
def find(ip_addr): new_ip = IP() row = new_ip.find_by_ip(ip_addr) if not row: logging.info("no entry found for %s", ip_addr) new_ip = lookup(ip_addr) logging.info(new_ip.data()) return logging.info(row[0].data())