Repository: CS-SI/eodag
Pull request #485 (2022-07-20 15:48:09)

feat: allow empty geometry for stac providers
Allows STAC providers to return `None` as item geometry, and use `[-180, -90, 180, 90]` as default value

github-actions[bot]: ## Unit Test Results
    2 files  ±0      2 suites  ±0   13m 47s [:stopwatch:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "duration of all tests") + 1m 22s
266 tests +1  264 [:heavy_check_mark:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "passed tests") +1  2 [:zzz:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "skipped / disabled tests") ±0  0 [:x:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "failed tests") ±0 
532 runs  +2  528 [:heavy_check_mark:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "passed tests") +2  4 [:zzz:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "skipped / disabled tests") ±0  0 [:x:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "failed tests") ±0 

Results for commit 80e54ac5. ± Comparison against base commit f6f97fe8.

[test-results]:data:application/gzip;base64,H4sIAJwm2GIC/02NOw7DIBAFr2JRpwDCsiiXidYYJBR/IgyVlbuH2Ji4nHnSvI35MLqVPTp569iaQ2ow5EgpLHNBI7GIMqV91Pqk55qt3ZX6q1d418QhPIWxCN6Ei3GJ1cQ8/5pwlxXOJEjTzFFUJ1+CO197dpmmkAowwx0osoBEXKHDgagX0DvUIIQshwjKI0f2+QKvTWT/BQEAAA==

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

| File | Coverage |   |
| - | :-: | :-: |
| **All files** | `80%` | :white_check_mark: |

<strong> </strong>

| File | Coverage |   |
| - | :-: | :-: |
| **All files** | `80%` | :white_check_mark: |

_Minimum allowed coverage is `70%`_

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

Patch:
diff --git a/eodag/resources/stac_provider.yml b/eodag/resources/stac_provider.yml
index 169c5dd8..e48a502c 100644
--- a/eodag/resources/stac_provider.yml
+++ b/eodag/resources/stac_provider.yml
@@ -134,7 +134,7 @@ search:
       - '$.id'
     geometry:
       - '{{"intersects":{geometry#to_geo_interface}}}'
-      - '$.geometry'
+      - '($.geometry.`str()`.`sub(/^None$/, POLYGON((180 -90, 180 90, -180 90, -180 -90, 180 -90)))`)|($.geometry[*])'
     downloadLink: '$.links[?(@.rel="self")].href'
     quicklook: '$.assets.quicklook.href'
     thumbnail: '$.assets.thumbnail.href'


Test patch:
diff --git a/tests/units/test_search_plugins.py b/tests/units/test_search_plugins.py
index 54515111..ca6c2456 100644
--- a/tests/units/test_search_plugins.py
+++ b/tests/units/test_search_plugins.py
@@ -395,3 +395,40 @@ class TestSearchPluginStacSearch(BaseSearchPluginTest):
             products[2].properties["productPath"],
             "products/2020/10/10/S2B_MSIL1C_20201010T012345_N0209_R008_T31TCJ_20201010T123456",
         )
+
+    @mock.patch("eodag.plugins.search.qssearch.StacSearch._request", autospec=True)
+    def test_plugins_search_stacsearch_default_geometry(self, mock__request):
+        """The metadata mapping for a stac provider should return a default geometry"""
+
+        geojson_geometry = self.search_criteria_s2_msi_l1c["geometry"].__geo_interface__
+
+        mock__request.return_value = mock.Mock()
+        mock__request.return_value.json.side_effect = [
+            {
+                "context": {"matched": 3},
+            },
+            {
+                "features": [
+                    {
+                        "id": "foo",
+                        "geometry": geojson_geometry,
+                    },
+                    {
+                        "id": "bar",
+                        "geometry": None,
+                    },
+                ]
+            },
+        ]
+
+        search_plugin = self.get_search_plugin(self.product_type, "earth_search")
+
+        products, estimate = search_plugin.query(
+            page=1,
+            items_per_page=3,
+            auth=None,
+        )
+        self.assertEqual(
+            products[0].geometry, self.search_criteria_s2_msi_l1c["geometry"]
+        )
+        self.assertEqual(products[1].geometry.bounds, (-180.0, -90.0, 180.0, 90.0))