Repository: CS-SI/eodag
Pull request #544 (2022-11-03 15:33:14)

refactor: remove unused code, templates and description.md
- removes unused template and `description.md`, following https://github.com/CS-SI/eodag/pull/529
- removes unused code block in `build_index()`

github-actions[bot]: ## Unit Test Results
    2 files  ±0      2 suites  ±0   7m 24s [:stopwatch:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "duration of all tests") -41s
299 tests ±0  296 [:heavy_check_mark:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "passed tests") ±0  2 [:zzz:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "skipped / disabled tests")  - 1  1 [:x:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "failed tests") +1 
598 runs  ±0  592 [:heavy_check_mark:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "passed tests") ±0  4 [:zzz:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "skipped / disabled tests")  - 2  2 [:x:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "failed tests") +2 

For more details on these failures, see [this check](https://github.com/CS-SI/eodag/runs/9276642245).

Results for commit 619e66e6. ± Comparison against base commit 837c127b.

[test-results]:data:application/gzip;base64,H4sIAJHgY2MC/02Myw7CIBAAf6Xh7AFaunT9GYOwTYh9GAon47+7tgU9zkwyLzGGiTZxbdpLI7YcUgWfo01hXRi11iw4pT0iFrpt2bldwU89wvNcHGK0YWKhqqAY18hGsol5+T57HE4oyx7bao6jLnwOa///uXWeQ2IQoJAACBT0FlVrvZHo7n4kNFZ1zlM3ABlpxPsDJKHLKQUBAAA=

github-actions[bot]: <strong> </strong>

| File | Coverage |   |
| - | :-: | :-: |
| **All files** | `84%` | :white_check_mark: |
| eodag/cli.py | `75%` | :white_check_mark: |
| eodag/api/core.py | `88%` | :white_check_mark: |

<strong> </strong>

| File | Coverage |   |
| - | :-: | :-: |
| **All files** | `83%` | :white_check_mark: |
| eodag/cli.py | `75%` | :white_check_mark: |
| eodag/api/core.py | `88%` | :white_check_mark: |
| eodag/cli.py | `74%` | :white_check_mark: |
| eodag/api/core.py | `87%` | :white_check_mark: |

_Minimum allowed coverage is `70%`_

<p align="right">Generated by :monkey: cobertura-action against 619e66e6165a912ad709cbdfe97a13cde386e707 </p>

Patch:
diff --git a/MANIFEST.in b/MANIFEST.in
index 1dff9554..1d2c73f2 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,5 +1,4 @@
 include README.rst LICENSE NOTICE requirements.txt
-include eodag/rest/description.md
 include eodag/rest/server.wsgi
 recursive-include docs *.rst
 graft eodag/resources
diff --git a/eodag/api/core.py b/eodag/api/core.py
index cd5d696b..ac9f28d8 100644
--- a/eodag/api/core.py
+++ b/eodag/api/core.py
@@ -254,10 +254,6 @@ class EODataAccessGateway(object):
                     }
                 )
             ix_writer.commit()
-        else:
-            if self._product_types_index is None:
-                logger.debug("Opening product types index in %s", index_dir)
-                self._product_types_index = open_dir(index_dir)
 
     def set_preferred_provider(self, provider):
         """Set max priority for the given provider.
@@ -1708,7 +1704,7 @@ class EODataAccessGateway(object):
         If the metadata mapping for ``downloadLink`` is set to something that can be
         interpreted as a link on a
         local filesystem, the download is skipped (by now, only a link starting
-        with ``file://`` is supported). Therefore, any user that knows how to extract
+        with ``file:/`` is supported). Therefore, any user that knows how to extract
         product location from product metadata on a provider can override the
         ``downloadLink`` metadata mapping in the right way. For example, using the
         environment variable:
@@ -1742,7 +1738,7 @@ class EODataAccessGateway(object):
         :raises: :class:`~eodag.utils.exceptions.PluginImplementationError`
         :raises: :class:`RuntimeError`
         """
-        if product.location.startswith("file://"):
+        if product.location.startswith("file:/"):
             logger.info("Local product detected. Download skipped")
             return uri_to_path(product.location)
         if product.downloader is None:
diff --git a/eodag/cli.py b/eodag/cli.py
index 0b052b74..51f38d9c 100755
--- a/eodag/cli.py
+++ b/eodag/cli.py
@@ -811,14 +811,6 @@ def deploy_wsgi_app(
         )
     )
     shutil.copy(os.path.join(webapp_src_path, "server.wsgi"), wsgi_path)
-    shutil.copy(
-        os.path.join(webapp_src_path, "description.md"),
-        os.path.join(webapp_dst_path, "description.md"),
-    )
-    shutil.copytree(
-        os.path.join(webapp_src_path, "templates"),
-        os.path.join(webapp_dst_path, "templates"),
-    )
 
     click.echo(
         "Overriding eodag HTTP server config with values: {}".format(server_config)
diff --git a/eodag/rest/description.md b/eodag/rest/description.md
deleted file mode 100644
index aaf26d8b..00000000
--- a/eodag/rest/description.md
+++ /dev/null
@@ -1,123 +0,0 @@
-# eodag-server
-
-eodag-server is a REST API for EODAG search tool implementing OpenSearch Geo interface.
-
-
-## Searching
-
-### By product type
-
-The server provides a GET endpoint with a route defined by:
-
-```
-http://hostname/<product_type>/?param=value
-```
-
-See below to get the list of available product types.
-
-Supported request parameters are:
-
-* `box`: the search bounding box defined by: min_lon,min_lat,max_lon,max_lat.
-* `dtstart`: the start date
-* `dtend`: the end date
-* `cloudCover`: cloud cover
-
-Example URL:
-
-<{base_url}S2_MSI_L1C/?box=0,43,1,44>
-
-It is also possible to paginate the result. Informations about pagination are returned in each response to a search
-request. Pagination paramaters are:
-
-* `page`: The page number (int, defaults to 1)
-* `itemsPerPage`: The maximum number of items per page (int, defaults to {ipp})
-
-### By UID
-
-Since version 1.0 of eodag, it is now possible to search directly an EO product based on its
-ID. The endpoint is the following:
-
-```
-http://hostname/<uid>/?provider=value
-```
-
-You can even specify on which provider to perform the request if you have this information.
-This may speed up your search.
-
-Example requests:
-
-<{base_url}search/S2B_MSIL1C_20180824T105019_N0206_R051_T30TYN_20180824T151058/>
-
-<{base_url}search/S2B_MSIL1C_20180824T105019_N0206_R051_T30TYN_20180824T151058/?provider=onda>
-
-## Filtering
-
-The service provides ability to filter search results by implemented EODAG crunchers.
-To activate a filter, add the 'filter' request parameter.
-
-Available filters and their matching EODAG cruncher are:
-
-* `latestIntersect` -> FilterLatestIntersect
-* `latestByName` -> FilterLatestByName
-* `overlap` -> FilterOverlap
-
-Some filters may require additional configuration parameters
-which can be set as request parameters.
-For example, overlap filter requires adding a 'minimum_overlap' parameter to the request.
-
-Example URL:
-
-<{base_url}S2_MSI_L1C/?box=0,43,1,44&filter=overlap&minimum_overlap=0>
-
-## Quicklooks
-
-Since version 1.0, an endpoint is available for retrieving EO products quicklooks based on
-their UID:
-
-```
-http://hostname/quicklook/<uid>/?provider=value
-```
-
-The UID is mandatory, and the provider query parameter can be provided to speed up the
-retrieval of the quicklook.
-
-Example URL (with a request on a provider known to make available the quicklook without authentication):
-
-<{base_url}quicklook/S2B_MSIL1C_20180824T105019_N0206_R051_T30TYN_20180824T151058/?provider=onda>
-
-The request for a quicklook may fail due to authentication problems or provider's access problem, or inconsistency
-between the URL given in the search result of the provider and the way to access this URL
-
-## Product types
-
-There is an endpoint for listing supported product types:
-
-* <{base_url}product-types/> for all providers supported product types or
-* <{base_url}product-types/$provider> for product types supported only by $provider.
-
-The result is a json with product type ID and metadata.
-
-The product types search can be filtered like this:
-
-```
-{base_url}product-types/?param1=value1&param2=value2
-```
-
-where parameters are:
-
-* `instrument`: the name of the instrument producing this type of product (e.g.: OLCI, TIRS). As a general rule, it is
-  the abbreviation of the commercial name of the instrument. Most of the time, this will be official
-* `platform`: the platform producing this type of products (e.g.: SENTINEL2, LANDSAT8). As a general rule, it is
-  constituted with the commercial name of the platform in capital letters, followed by a number - if any
-* `platformSerialIdentifier`: an identifier of the platform (e.g.: S2A, L8). As a general rule, it is constituted with
-  the first letter of the platform in capitals, followed by a number of the platform if any, and a letter from A to Z
-  if there are many satellite for this platform. If the platform does not have a number, a trigram will be used as an
-  identifier. Also, if there is a well-known international standard serial identifier for the platform, it will be used
-* `processingLevel`: the processing level of the product type (e.g.: L1, L2, L0). In general, it is constituted by `L`
-  and the a number from 0 onward indicating the level number
-* `sensorType`: the type of censor (e.g.: OPTICAL, RADAR). This tries to follow as much as possible
-  [This OGC standard](https://www.opengeospatial.org/standards/cat2eoext4ebrim)
-
-Supported product types are:
-
-{product_types}
diff --git a/eodag/rest/templates/README b/eodag/rest/templates/README
new file mode 100644
index 00000000..6e28e4fc
--- /dev/null
+++ b/eodag/rest/templates/README
@@ -0,0 +1,1 @@
+Empty templates directory kept for compatibility reasons
diff --git a/eodag/rest/templates/index.html b/eodag/rest/templates/index.html
deleted file mode 100644
index a147e9c7..00000000
--- a/eodag/rest/templates/index.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<!doctype html>
-<html>
-  <head>
-    <title>EODAG Server</title>
-  </head>
-  <body>
-    {{ content|safe }}
-  </body>
-</html>


Test patch:
diff --git a/tests/units/test_core.py b/tests/units/test_core.py
index f3514a29..c109a695 100644
--- a/tests/units/test_core.py
+++ b/tests/units/test_core.py
@@ -1498,3 +1498,34 @@ class TestCoreSearch(TestCoreBase):
         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)
+
+
+class TestCoreDownload(TestCoreBase):
+    @classmethod
+    def setUpClass(cls):
+        super(TestCoreDownload, cls).setUpClass()
+        cls.dag = EODataAccessGateway()
+
+    def test_download_local_product(self):
+        """download must skip local products"""
+        product = EOProduct("dummy", dict(geometry="POINT (0 0)", id="dummy_product"))
+
+        product.location = "file:///some/path"
+        with self.assertLogs(level="INFO") as cm:
+            self.dag.download(product)
+            self.assertIn("Local product detected. Download skipped", str(cm.output))
+
+        product.location = "file:/some/path"
+        with self.assertLogs(level="INFO") as cm:
+            self.dag.download(product)
+            self.assertIn("Local product detected. Download skipped", str(cm.output))
+
+        product.location = "file:///c:/some/path"
+        with self.assertLogs(level="INFO") as cm:
+            self.dag.download(product)
+            self.assertIn("Local product detected. Download skipped", str(cm.output))
+
+        product.location = "file:/c:/some/path"
+        with self.assertLogs(level="INFO") as cm:
+            self.dag.download(product)
+            self.assertIn("Local product detected. Download skipped", str(cm.output))
diff --git a/tests/units/test_utils.py b/tests/units/test_utils.py
index d5596270..8616d6c2 100644
--- a/tests/units/test_utils.py
+++ b/tests/units/test_utils.py
@@ -62,11 +62,15 @@ class TestUtils(unittest.TestCase):
         if sys.platform == "win32":
             expected_path = r"C:\tmp\file.txt"
             tested_uri = r"file:///C:/tmp/file.txt"
+            other_tested_uri = r"file:/C:/tmp/file.txt"
         else:
             expected_path = "/tmp/file.txt"
             tested_uri = "file:///tmp/file.txt"
+            other_tested_uri = "file:/tmp/file.txt"
         actual_path = uri_to_path(tested_uri)
         self.assertEqual(actual_path, expected_path)
+        actual_path = uri_to_path(other_tested_uri)
+        self.assertEqual(actual_path, expected_path)
         with self.assertRaises(ValueError):
             uri_to_path("not_a_uri")