Skip to content

Commit 56ec845

Browse files
committed
test: added invalid tests
1 parent 83f60c6 commit 56ec845

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

tests/test_opensearch.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22
from data.test_data import OPENSEARCH_PRODUCT_TYPES
3-
from eodm.opensearch import OpenSearchClient
3+
from eodm.opensearch import OpenSearchClient, OpenSearchException
44

55

66
@pytest.mark.parametrize("opensearch_product_type", OPENSEARCH_PRODUCT_TYPES)
@@ -14,3 +14,25 @@ def test_opensearch_search(
1414
query = {"{count}": 3, "{eo:productType}": opensearch_product_type}
1515
for i in client.search(query):
1616
assert i
17+
18+
19+
def test_opensearch_invalid_product_type(mock_opensearch_describe):
20+
client = OpenSearchClient(
21+
"https://finder.creodias.eu/resto/api/collections/describe.xml"
22+
)
23+
24+
query = {"{count}": 3, "{eo:productType}": "INVALID"}
25+
with pytest.raises(OpenSearchException):
26+
for i in client.search(query):
27+
i
28+
29+
30+
def test_opensearch_invalid_count(mock_opensearch_describe):
31+
client = OpenSearchClient(
32+
"https://finder.creodias.eu/resto/api/collections/describe.xml"
33+
)
34+
35+
query = {"{count}": -5, "{eo:productType}": OPENSEARCH_PRODUCT_TYPES[0]}
36+
with pytest.raises(OpenSearchException):
37+
for i in client.search(query):
38+
i

0 commit comments

Comments
 (0)