Repository: CS-SI/eodag
Pull request #597 (2022-12-23 09:50:27)

fix: ordered keywords in discovered product types
following #592, sort keywords for discovered product types to prevent unneeded PRs from github-actions bot

github-actions[bot]: ## Unit Test Results
    2 files  ±    0      2 suites  ±0   10m 6s [:stopwatch:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "duration of all tests") - 2m 29s
334 tests +    1  330 [:heavy_check_mark:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "passed tests") ±    0  3 [: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  1 [:fire:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "test errors") +1 
533 runs   - 133  527 [:heavy_check_mark:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "passed tests")  - 133  4 [:zzz:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "skipped / disabled tests")  - 2  0 [:x:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "failed tests") ±0  2 [:fire:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "test errors") +2 

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

Results for commit adbd0396. ± Comparison against base commit ca5c8241.

[test-results]:data:application/gzip;base64,H4sIAM57pWMC/03Oyw6DIBCF4VcxrLtArtqXaUYYE1IvDcLK9N072KJd/t+QE3Y2hgk3dm/ErWFbDukMnyOksC6UhhsCOqVylFLVemzZuYP4Rc/wKnTCCGEiuF5gjGskaUliXsqmlvIXdVILe8p3UdX+Gzy67pVfu3WeQ6Jg4AfPZW8G6wGM7gEFat56JEXXCd51XFlE9v4Aw81yYgUBAAA=

github-actions[bot]: _Minimum allowed coverage is `70%`_

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

Patch:
diff --git a/eodag/plugins/search/qssearch.py b/eodag/plugins/search/qssearch.py
index dda336da..aec4e4a9 100644
--- a/eodag/plugins/search/qssearch.py
+++ b/eodag/plugins/search/qssearch.py
@@ -279,14 +279,19 @@ class QueryStringSearch(Search):
                                 != NOT_AVAILABLE
                             ]
                         )
-                        keywords_values_str = keywords_values_str.replace(
-                            ", ", ","
-                        ).replace(" ", "-")
+                        # cleanup str list from unwanted characters
+                        keywords_values_str = (
+                            keywords_values_str.replace(", ", ",")
+                            .replace(" ", "-")
+                            .replace("_", "-")
+                            .lower()
+                        )
                         keywords_values_str = re.sub(
                             r"[\[\]'\"]", "", keywords_values_str
                         )
+                        # sorted list of unique lowercase keywords
                         keywords_values_str = ",".join(
-                            set(keywords_values_str.split(","))
+                            sorted(set(keywords_values_str.split(",")))
                         )
                         conf_update_dict["product_types_config"][
                             generic_product_type_id


Test patch:
diff --git a/tests/units/test_search_plugins.py b/tests/units/test_search_plugins.py
index b25b7ea7..142ca61f 100644
--- a/tests/units/test_search_plugins.py
+++ b/tests/units/test_search_plugins.py
@@ -205,10 +205,10 @@ class TestSearchPluginQueryStringSearch(BaseSearchPluginTest):
                     "id": "foo_collection",
                     "keywords": ["foo", "bar"],
                     "summaries": {
-                        "instruments": ["baz"],
+                        "instruments": ["baZ"],
                         "constellation": "qux,foo",
                         "platform": ["quux", "corge", "bar"],
-                        "processing:level": "grault",
+                        "processing:level": "GRAULT",
                     },
                 },
             ]
@@ -218,18 +218,19 @@ class TestSearchPluginQueryStringSearch(BaseSearchPluginTest):
             "keywords"
         ].split(",")
 
-        self.assertEqual(len(keywords_list), 8)
-        for k in [
-            "foo_collection",
-            "foo",
-            "bar",
-            "baz",
-            "qux",
-            "quux",
-            "corge",
-            "grault",
-        ]:
-            self.assertIn(k, keywords_list)
+        self.assertEqual(
+            [
+                "bar",
+                "baz",
+                "corge",
+                "foo",
+                "foo-collection",
+                "grault",
+                "quux",
+                "qux",
+            ],
+            keywords_list,
+        )
 
 
 class TestSearchPluginPostJsonSearch(BaseSearchPluginTest):