Пример #1
0
 def test_save_stations_from_page(self):
     path = tempfile.mkdtemp()
     try:
         count = milk.save_station_from_page(path, 1, self.CACHE_DIR)
         files = glob.glob(os.path.join(path, "station_*.json"))
         self.assertEquals(15, count)
         for filename in files:
             with open(filename) as f:
                 d = json.load(f)
                 self.assertEquals(os.path.join(path, "station_%d.json" % d['id']),
                                   filename)
     finally:
         shutil.rmtree(path)
Пример #2
0
 def test_save_stations_from_page(self):
     path = tempfile.mkdtemp()
     try:
         count = milk.save_station_from_page(path, 1, self.CACHE_DIR)
         files = glob.glob(os.path.join(path, "station_*.json"))
         self.assertEquals(15, count)
         for filename in files:
             with open(filename) as f:
                 d = json.load(f)
                 self.assertEquals(
                     os.path.join(path, "station_%d.json" % d['id']),
                     filename)
     finally:
         shutil.rmtree(path)
Пример #3
0
 def test_geocode_all_stations(self):
     path = tempfile.mkdtemp()
     try:
         station_count = milk.save_station_from_page(path, 1, self.CACHE_DIR)
         count = milk.geocode_station_files(self.CACHE_DIR, path)
         print station_count
         print count
         self.assertEquals(station_count, count)
         files = glob.glob(os.path.join(path, "geodata_*.json"))
         self.assertEquals(station_count, len(files))
         for filename in files:
             with open(filename) as f:
                 d = json.load(f)
                 self.assertIsInstance(d, dict)
                 #self.assertIn(d, 'status')
     finally:
         shutil.rmtree(path)
Пример #4
0
 def test_geocode_all_stations(self):
     path = tempfile.mkdtemp()
     try:
         station_count = milk.save_station_from_page(
             path, 1, self.CACHE_DIR)
         count = milk.geocode_station_files(self.CACHE_DIR, path)
         print station_count
         print count
         self.assertEquals(station_count, count)
         files = glob.glob(os.path.join(path, "geodata_*.json"))
         self.assertEquals(station_count, len(files))
         for filename in files:
             with open(filename) as f:
                 d = json.load(f)
                 self.assertIsInstance(d, dict)
                 #self.assertIn(d, 'status')
     finally:
         shutil.rmtree(path)