def test_main_options(self): """ Test main program with output options """ fname = os.path.join(testpath, 'test_main-save.json') items = main(datetime='2019-07-01', save=fname, printcal=True, printmd=[], property=['eo:platform=landsat-8']) self.assertEqual(len(items), self.num_scenes) self.assertTrue(os.path.exists(fname)) os.remove(fname) self.assertFalse(os.path.exists(fname))
def test_main_options(self): """ Test main program with output options """ fname = os.path.join(testpath, 'test_main-save.json') items = main(datetime='2020-01-01', save=fname, printcal=True, printmd=[], collections=['sentinel-s2-l2a'], query=['eo:cloud_cover=0', 'data_coverage>80']) self.assertEqual(len(items), 212) self.assertTrue(os.path.exists(fname)) os.remove(fname) self.assertFalse(os.path.exists(fname))
def test_main_download(self): """ Test main program with downloading """ with open(os.path.join(testpath, 'aoi1.geojson')) as f: aoi = json.dumps(json.load(f)) config.DATADIR = os.path.join(testpath, "${eo:platform}") items = main(datetime='2019-06-05/2019-06-21', intersects=aoi, download=['thumbnail', 'MTL'], **{'collection': 'landsat-8-l1'}) for item in items: bname = os.path.splitext(item.get_filename(config.DATADIR))[0] assert(os.path.exists(bname + '_thumbnail.jpg')) if not os.path.exists(bname + '_MTL.txt'): import pdb; pdb.set_trace() assert(os.path.exists(bname + '_MTL.txt')) shutil.rmtree(os.path.join(testpath,'landsat-8')) config.DATADIR = testpath
def test_main_download(self): """ Test main program with downloading """ with open(os.path.join(testpath, 'aoi1.geojson')) as f: aoi = json.load(f) filename_template = os.path.join(testpath, "test-download/${platform}/${id}") items = main(datetime='2020-06-07', intersects=aoi['geometry'], filename_template=filename_template, download=['thumbnail', 'info'], **{'collections': ['sentinel-s2-l1c']}) for item in items: bname = os.path.splitext(item.get_path(filename_template))[0] assert (os.path.exists(bname + '_thumbnail.jpg')) assert (os.path.exists(bname + '_info.json'))
def test_main_load(self): items = main(items=os.path.join(testpath, 'scenes.geojson')) assert (len(items) == 2)
def test_main_found(self): """ Run main function """ found = main(datetime='2020-01-01', found=True) self.assertEqual(found, 17819)
def test_main(self): """ Run main function """ items = main(datetime='2020-01-01', collections=['sentinel-s2-l1c'], query=['eo:cloud_cover=0', 'data_coverage>80']) self.assertEqual(len(items), 207)
def test_main_found(self): """ Run main function """ found = main(datetime='2020-01-01', found=True) min_found = 17819 assert (found >= min_found)
def test_main_found(self): """ Run main function """ found = main(datetime='2019-07-01', found=True) self.assertEqual(found, 24737)
def test_main_found(self): """ Run main function """ found = main(datetime='2019-07-01', found=True, **{'collection': 'landsat-8-l1'}) self.assertEqual(found, self.num_scenes)
def test_main(self): """ Run main function """ items = main(datetime='2019-07-01', **{'collection': 'landsat-8-l1'}) self.assertEqual(len(items), self.num_scenes)