Repository: CS-SI/eodag
Pull request #822 (2023-09-12 13:05:37)

fix: update server body model to search by ids
Update server body model to search by ids (missing `ids` parameter)

Related to #776 

github-actions[bot]: ## Test Results
       4 files  ±0         4 suites  ±0   5m 44s [:stopwatch:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v2.9.0/README.md#the-symbols "duration of all tests") -11s
   413 tests ±0     411 [:heavy_check_mark:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v2.9.0/README.md#the-symbols "passed tests") ±0    2 [:zzz:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v2.9.0/README.md#the-symbols "skipped / disabled tests") ±0  0 [:x:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v2.9.0/README.md#the-symbols "failed tests") ±0 
1 652 runs  ±0  1 584 [:heavy_check_mark:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v2.9.0/README.md#the-symbols "passed tests") ±0  68 [:zzz:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v2.9.0/README.md#the-symbols "skipped / disabled tests") ±0  0 [:x:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v2.9.0/README.md#the-symbols "failed tests") ±0 

Results for commit dcb84876. ± Comparison against base commit e100b96b.

[test-results]:data:application/gzip;base64,H4sIAMJjAGUC/03MSw7CIBSF4a00jB1wKVyubsYglITYh6EwMu5dWgt2+H8nOW/mwzis7NbJS8fWHFILl6NJYZlL9nKDMqV9hL7Wfc3W7gR/eoZXIdHAmzAW4A2GGJd4SMzz9gmoxFH1ExTJRr9PpAqnz73Pl3aZppBKMGcfJEkj11Z55ATozBU0CAUGSaLkg3aCE/t8Aeoy5HUIAQAA

github-actions[bot]: <strong>Code Coverage (Ubuntu)</strong>

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

_Minimum allowed coverage is `70%`_

<p align="right">Generated by :monkey: cobertura-action against dcb8487607c5f60816da9171251a684640e7d208 </p>
github-actions[bot]: <strong>Code Coverage (Windows)</strong>

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

_Minimum allowed coverage is `70%`_

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

Patch:
diff --git a/eodag/rest/server.py b/eodag/rest/server.py
index 7364fe8b..d461692b 100755
--- a/eodag/rest/server.py
+++ b/eodag/rest/server.py
@@ -308,6 +308,7 @@ class SearchBody(BaseModel):
     limit: Union[int, None] = 20
     page: Union[int, None] = 1
     query: Union[dict, None] = None
+    ids: Union[List[str], None] = None
 
 
 @router.get("/search", tags=["STAC"])


Test patch:
diff --git a/tests/units/test_http_server.py b/tests/units/test_http_server.py
index ca986da8..de3db507 100644
--- a/tests/units/test_http_server.py
+++ b/tests/units/test_http_server.py
@@ -252,6 +252,7 @@ class RequestTestCase(unittest.TestCase):
         expected_search_kwargs=None,
         protocol="GET",
         post_data=None,
+        search_call_count=None,
     ):
         if protocol == "GET":
             response = self.app.get(url, follow_redirects=True)
@@ -262,7 +263,22 @@ class RequestTestCase(unittest.TestCase):
                 follow_redirects=True,
             )
 
-        if expected_search_kwargs is not None:
+        if search_call_count is not None:
+            self.assertEqual(mock_search.call_count, search_call_count)
+
+        if (
+            expected_search_kwargs is not None
+            and search_call_count is not None
+            and search_call_count > 1
+        ):
+            self.assertIsInstance(
+                expected_search_kwargs,
+                list,
+                "expected_search_kwargs must be a list if search_call_count > 1",
+            )
+            for single_search_kwargs in expected_search_kwargs:
+                mock_search.assert_any_call(**single_search_kwargs)
+        elif expected_search_kwargs is not None:
             mock_search.assert_called_once_with(**expected_search_kwargs)
 
         self.assertEqual(200, response.status_code, response.text)
@@ -275,12 +291,14 @@ class RequestTestCase(unittest.TestCase):
         expected_search_kwargs=None,
         protocol="GET",
         post_data=None,
+        search_call_count=None,
     ):
         response = self._request_valid_raw(
             url,
             expected_search_kwargs=expected_search_kwargs,
             protocol=protocol,
             post_data=post_data,
+            search_call_count=search_call_count,
         )
 
         # Assert response format is GeoJSON
@@ -553,6 +571,19 @@ class RequestTestCase(unittest.TestCase):
                 "collections": [self.tested_product_type],
                 "ids": ["foo", "bar"],
             },
+            search_call_count=2,
+            expected_search_kwargs=[
+                {
+                    "provider": None,
+                    "id": "foo",
+                    "productType": self.tested_product_type,
+                },
+                {
+                    "provider": None,
+                    "id": "bar",
+                    "productType": self.tested_product_type,
+                },
+            ],
         )
 
     def test_search_response_contains_pagination_info(self):