Repository: CS-SI/eodag
Pull request #694 (2023-04-05 14:48:29)

fix: guess_product_type should return given productType if specified
`guess_product_type()` should return given `productType` if specified

github-actions[bot]: ## Test Results
    2 files  ±0      2 suites  ±0   2m 14s [:stopwatch:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "duration of all tests") -40s
379 tests ±0  376 [: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 
758 runs  ±0  752 [:heavy_check_mark:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "passed tests") ±0  6 [: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 3533c0be. ± Comparison against base commit 324bc80d.

[test-results]:data:application/gzip;base64,H4sIAGqLLWQC/03MQQ6DIBCF4asY1l2MMoj0Mg2MmJCqNAirpncvWKUu/+8l780mN9uN3Zvu1rAtuVhjTEFH59ecLccMeYpl5FKd9dgS0U79n57uVajCpN2cASrYEHw4JKS1fEoxHHFeStFV+T32Z18O977+kV8WF3MwLjgnMNYosArQCOq7QRsrAMeJoEUkQJLIPl/FCPlWBQEAAA==

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

| File | Coverage |   |
| - | :-: | :-: |
| **All files** | `88%` | :white_check_mark: |
| eodag/api/core.py | `93%` | :white_check_mark: |
| tests/units/test\_core.py | `98%` | :white_check_mark: |

<strong> </strong>

| File | Coverage |   |
| - | :-: | :-: |
| **All files** | `88%` | :white_check_mark: |
| eodag/api/core.py | `93%` | :white_check_mark: |
| tests/units/test\_core.py | `98%` | :white_check_mark: |
| eodag/api/core.py | `92%` | :white_check_mark: |
| tests/units/test\_core.py | `98%` | :white_check_mark: |

_Minimum allowed coverage is `70%`_

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

Patch:
diff --git a/eodag/api/core.py b/eodag/api/core.py
index 29f11a6c..c20d4bfe 100644
--- a/eodag/api/core.py
+++ b/eodag/api/core.py
@@ -787,6 +787,8 @@ class EODataAccessGateway(object):
         :rtype: list[str]
         :raises: :class:`~eodag.utils.exceptions.NoMatchingProductType`
         """
+        if kwargs.get("productType", None):
+            return [kwargs["productType"]]
         supported_params = {
             param
             for param in (


Test patch:
diff --git a/tests/units/test_core.py b/tests/units/test_core.py
index eabc50d4..9dacdfd5 100644
--- a/tests/units/test_core.py
+++ b/tests/units/test_core.py
@@ -1157,6 +1157,10 @@ class TestCoreSearch(TestCoreBase):
         ]
         self.assertEqual(actual, expected)
 
+        # with product type specified
+        actual = self.dag.guess_product_type(productType="foo")
+        self.assertEqual(actual, ["foo"])
+
     def test_guess_product_type_without_kwargs(self):
         """guess_product_type must raise an exception when no kwargs are provided"""
         with self.assertRaises(NoMatchingProductType):