def test_find_many_products(): _images_a_recuperer = 1000 results = theia.find_products(nb_resultats_max=_images_a_recuperer) assert type(results) == theia.Results assert len(results) == _images_a_recuperer for result in results: assert result.collection == "SENTINEL2"
def main(): start = datetime.strptime(_START_DATE, "%Y-%m-%d") end = datetime.strptime(_END_DATE, "%Y-%m-%d") while start < end: day_str = start.strftime("%Y-%m-%d") next_day = start + timedelta(days=1) next_day_str = next_day.strftime("%Y-%m-%d") print("Search products for {}".format(day_str)) results = theia.find_products(start_date=day_str, end_date=next_day_str, nb_resultats_max=100000) print("{} results for {}".format(len(results), day_str)) if len(results) > 0: filename = "theia_{}.json".format(day_str) with open(filename, "w") as f: for result in results: f.write(result_to_kibana(result)) start = start + timedelta(days=1) # increase day one by one
def test_find_products_for_one_specific_day(): results = theia.find_products(start_date="2018-01-01", end_date="2018-01-02", nb_resultats_max=5) assert type(results) == theia.Results print() for result in results: print(result.acquisition_date) assert "2018-01-01" in result.acquisition_date
def test_find_products_with_pagination(): # Pour tester que la fonction peut rechercher au-delà de la 1ère page de # résultats, on demande le nombre max + 1 _images_a_recuperer = theia._MAX_RESULTS_PER_THEIA_REQUEST + 1 results = theia.find_products(nb_resultats_max=_images_a_recuperer) assert type(results) == theia.Results assert len(results) == _images_a_recuperer for result in results: assert result.collection == "SENTINEL2"