Exemplo n.º 1
0
 def test_search_all_user_items_per_page(self, mocked_search_iter_page):
     """search_all must use the value of items_per_page provided by the user"""
     dag = EODataAccessGateway()
     dummy_provider_config = """
     dummy_provider:
         search:
             type: QueryStringSearch
             api_endpoint: https://api.my_new_provider/search
             metadata_mapping:
                 dummy: 'dummy'
         products:
             S2_MSI_L1C:
                 productType: '{productType}'
     """
     mocked_search_iter_page.return_value = (self.search_results
                                             for _ in range(1))
     dag.update_providers_config(dummy_provider_config)
     dag.set_preferred_provider("dummy_provider")
     dag.search_all(productType="S2_MSI_L1C", items_per_page=7)
     self.assertEqual(
         mocked_search_iter_page.call_args[1]["items_per_page"], 7)
Exemplo n.º 2
0
 def test_search_all_use_default_value(self, mocked_search_iter_page):
     """search_all must use the DEFAULT_MAX_ITEMS_PER_PAGE if the provider's one wasn't configured"""  # noqa
     dag = EODataAccessGateway()
     dummy_provider_config = """
     dummy_provider:
         search:
             type: QueryStringSearch
             api_endpoint: https://api.my_new_provider/search
             metadata_mapping:
                 dummy: 'dummy'
         products:
             S2_MSI_L1C:
                 productType: '{productType}'
     """
     mocked_search_iter_page.return_value = (self.search_results
                                             for _ in range(1))
     dag.update_providers_config(dummy_provider_config)
     dag.set_preferred_provider("dummy_provider")
     dag.search_all(productType="S2_MSI_L1C")
     self.assertEqual(
         mocked_search_iter_page.call_args[1]["items_per_page"],
         DEFAULT_MAX_ITEMS_PER_PAGE,
     )
Exemplo n.º 3
0
 def test_search_all_use_max_items_per_page(self, mocked_search_iter_page):
     """search_all must use the configured parameter max_items_per_page if available"""  # noqa
     dag = EODataAccessGateway()
     dummy_provider_config = """
     dummy_provider:
         search:
             type: QueryStringSearch
             api_endpoint: https://api.my_new_provider/search
             pagination:
                 max_items_per_page: 2
             metadata_mapping:
                 dummy: 'dummy'
         products:
             S2_MSI_L1C:
                 productType: '{productType}'
     """
     mocked_search_iter_page.return_value = (self.search_results
                                             for _ in range(1))
     dag.update_providers_config(dummy_provider_config)
     dag.set_preferred_provider("dummy_provider")
     dag.search_all(productType="S2_MSI_L1C")
     self.assertEqual(
         mocked_search_iter_page.call_args[1]["items_per_page"], 2)