Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: guess_product_type should return given productType if specified #694

Merged
merged 1 commit into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions eodag/api/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,8 @@ def guess_product_type(self, **kwargs):
:rtype: list[str]
:raises: :class:`~eodag.utils.exceptions.NoMatchingProductType`
"""
if kwargs.get("productType", None):
return [kwargs["productType"]]
supported_params = {
param
for param in (
Expand Down
4 changes: 4 additions & 0 deletions tests/units/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,10 @@ def test_guess_product_type_with_kwargs(self):
]
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):
Expand Down