Skip to content

Commit c679571

Browse files
committed
In this commit actually, implemented more tests
1 parent 141e2c4 commit c679571

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed

src/PRIP/tests/conftest.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import pytest
2+
from prip_station_mock import create_prip_app
3+
import json
4+
import pathlib
5+
6+
@pytest.fixture
7+
def prip_client():
8+
"""Docstring to be added."""
9+
app = create_prip_app()
10+
with app.test_client() as client:
11+
yield client
12+
13+
PATH_TO_CONFIG = pathlib.Path(__file__).parent.parent.resolve() / "config"
14+
15+
with open(PATH_TO_CONFIG / "Catalog" / "GETFileResponse.json") as bdata:
16+
data = json.loads(bdata.read())['Data']
17+
18+
PRIP_PRODUCT = data[0]
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import pytest
2+
from http import HTTPStatus
3+
from conftest import PRIP_PRODUCT
4+
import json
5+
6+
# There are like 200k combinations, test list of most used
7+
@pytest.mark.parametrize("url, response", [
8+
("/Products?$expand=Attributes", PRIP_PRODUCT),
9+
("/Products?$filter=contains(Name, 'IW_RAW__0NSH')&$expand=Attributes", PRIP_PRODUCT),
10+
("/Products?$filter=contains(Name, 'NOT_FOUND')&$expand=Attributes", None),
11+
("/Products?$filter=startswith(Name, 'S1A_IW')&$expand=Attributes", PRIP_PRODUCT),
12+
("/Products?$filter=startswith(Name, 'INVALID')&$expand=Attributes", None),
13+
("/Products?$filter=endswith(Name, 'SAFE.zip')&$expand=Attributes", PRIP_PRODUCT),
14+
("/Products?$filter=endswith(Name, 'INVALID')&$expand=Attributes", None),
15+
("/Products?$filter=startswith(Name, 'S1A_IW') and endswith(Name, 'SAFE.zip')&$expand=Attributes", PRIP_PRODUCT),
16+
("/Products?$filter=contains(Name, 'IW_RAW__0NSH') and endswith(Name, 'SAFE.zip')&$expand=Attributes", PRIP_PRODUCT),
17+
#("/Products?$filter=startswith(Name, 'INVALID') and endswith(Name, 'SAFE.zip')&$expand=Attributes", None),
18+
("/Products?$filter=startswith(Name, 'S1A_IW') and endswith(Name, 'INVALID')&$expand=Attributes", None),
19+
("/Products?$filter=EvictionDate eq 9999-12-31T23:59:59.999Z&$expand=Attributes", PRIP_PRODUCT),
20+
("/Products?$filter=ModificationDate eq 2022-06-26T06:30:34.558Z&$expand=Attributes", PRIP_PRODUCT),
21+
("/Products?$filter=OriginDate eq 2022-06-26T06:14:55.468Z&$expand=Attributes", PRIP_PRODUCT),
22+
("/Products?$filter=PublicationDate eq 2022-06-26T06:30:34.558Z&$expand=Attributes", PRIP_PRODUCT),
23+
#("/Products?$filter=Online eq true&$expand=Attributes", PRIP_PRODUCT),
24+
("/Products?$filter=ContentDate/Start eq 2022-06-26T05:05:33.863Z&$expand=Attributes", PRIP_PRODUCT),
25+
("/Products?$filter=ContentDate/End eq 2022-06-26T05:10:38.849Z&$expand=Attributes", PRIP_PRODUCT),
26+
("/Products?$filter=OData.CSC.Intersects(area=geography'SRID=4326;POLYGON((-60 0,-62 -10,-58 -10,-56 0,-60 0))')&$expand=Attributes", PRIP_PRODUCT),
27+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'polarisationChannels' and att/OData.CSC.StringAttribute/Value eq 'HH')&$expand=Attributes", PRIP_PRODUCT),
28+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'productType' and att/OData.CSC.StringAttribute/Value eq 'IW_RAW__0N')&$expand=Attributes", PRIP_PRODUCT),
29+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'cycleNumber' and att/OData.CSC.StringAttribute/Value eq '265')&$expand=Attributes", PRIP_PRODUCT),
30+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'relativeOrbitNumber' and att/OData.CSC.StringAttribute/Value eq '43829')&$expand=Attributes", PRIP_PRODUCT),
31+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'processingCenter' and att/OData.CSC.StringAttribute/Value eq 'S1 Production Service-SERCO')&$expand=Attributes", PRIP_PRODUCT),
32+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'completionTimeFromAscendingNode' and att/OData.CSC.StringAttribute/Value eq '4646455.264')&$expand=Attributes", PRIP_PRODUCT),
33+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'processingDate' and att/OData.CSC.StringAttribute/Value eq '2022-06-26T06:11:22.535Z')&$expand=Attributes", PRIP_PRODUCT),
34+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'datatakeID' and att/OData.CSC.StringAttribute/Value eq '342911')&$expand=Attributes", PRIP_PRODUCT),
35+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'orbitNumber' and att/OData.CSC.StringAttribute/Value eq '43829')&$expand=Attributes", PRIP_PRODUCT),
36+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'productConsolidation' and att/OData.CSC.StringAttribute/Value eq 'FULL')&$expand=Attributes", PRIP_PRODUCT),
37+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'endingDateTime' and att/OData.CSC.StringAttribute/Value eq '2022-06-26T05:10:38.849Z')&$expand=Attributes", PRIP_PRODUCT),
38+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'qualityDataObjectID' and att/OData.CSC.StringAttribute/Value eq 'measurementData')&$expand=Attributes", PRIP_PRODUCT),
39+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'coordinates' and att/OData.CSC.StringAttribute/Value eq '-59.3169 2.6367,-63.105 -14.0539,-60.8506 -14.4245,-57.13092.3269,-59.3169 2.6367')&$expand=Attributes", PRIP_PRODUCT),
40+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'orbitDirection' and att/OData.CSC.StringAttribute/Value eq 'ASCENDING')&$expand=Attributes", PRIP_PRODUCT),
41+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'sliceProductFlag' and att/OData.CSC.StringAttribute/Value eq 'False')&$expand=Attributes", PRIP_PRODUCT),
42+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'beginningDateTime' and att/OData.CSC.StringAttribute/Value eq '2022-06-26T05:05:33.863Z')&$expand=Attributes", PRIP_PRODUCT),
43+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'instrumentConfigurationID' and att/OData.CSC.StringAttribute/Value eq '7')&$expand=Attributes", PRIP_PRODUCT),
44+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'startTimeFromAscendingNode' and att/OData.CSC.StringAttribute/Value eq '4341469.328')&$expand=Attributes", PRIP_PRODUCT),
45+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'instrumentShortName' and att/OData.CSC.StringAttribute/Value eq 'SAR')&$expand=Attributes", PRIP_PRODUCT),
46+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'productClass' and att/OData.CSC.StringAttribute/Value eq 'N')&$expand=Attributes", PRIP_PRODUCT),
47+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'platformShortName' and att/OData.CSC.StringAttribute/Value eq 'SENTINEL-1')&$expand=Attributes", PRIP_PRODUCT),
48+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'platformSerialIdentifier' and att/OData.CSC.StringAttribute/Value eq 'A')&$expand=Attributes", PRIP_PRODUCT),
49+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'platformShortName' and att/OData.CSC.StringAttribute/Value eq 'SENTINEL-1') and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'instrumentShortName' and att/OData.CSC.StringAttribute/Value eq 'SAR')&$expand=Attributes", PRIP_PRODUCT),
50+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'polarisationChannels' and att/OData.CSC.StringAttribute/Value eq 'HH') and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'productType' and att/OData.CSC.StringAttribute/Value eq 'IW_RAW__0N')&$expand=Attributes", PRIP_PRODUCT),
51+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'cycleNumber' and att/OData.CSC.StringAttribute/Value eq '265') and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'orbitNumber' and att/OData.CSC.StringAttribute/Value eq '43829')&$expand=Attributes", PRIP_PRODUCT),
52+
("/Products?$filter=EvictionDate eq 9999-12-31T23:59:59.999Z and OriginDate eq 2022-06-26T06:14:55.468Z&$expand=Attributes", PRIP_PRODUCT),
53+
("/Products?$filter=startswith(Name, 'S1A_IW') and endswith(Name, 'SAFE.zip')&$expand=Attributes", PRIP_PRODUCT),
54+
("/Products?$filter=ContentDate/Start eq 2022-06-26T05:05:33.863Z and ContentDate/End eq 2022-06-26T05:10:38.849Z&$expand=Attributes", PRIP_PRODUCT),
55+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'startTimeFromAscendingNode' and att/OData.CSC.StringAttribute/Value eq '4341469.328') and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'completionTimeFromAscendingNode' and att/OData.CSC.StringAttribute/Value eq '4646455.264')&$expand=Attributes", PRIP_PRODUCT),
56+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'datatakeID' and att/OData.CSC.StringAttribute/Value eq '342911') and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'processingDate' and att/OData.CSC.StringAttribute/Value eq '2022-06-26T06:11:22.535Z')&$expand=Attributes", PRIP_PRODUCT),
57+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'orbitDirection' and att/OData.CSC.StringAttribute/Value eq 'ASCENDING') and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'productClass' and att/OData.CSC.StringAttribute/Value eq 'N')&$expand=Attributes", PRIP_PRODUCT),
58+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'platformSerialIdentifier' and att/OData.CSC.StringAttribute/Value eq 'A') and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'processingCenter' and att/OData.CSC.StringAttribute/Value eq 'S1 Production Service-SERCO')&$expand=Attributes", PRIP_PRODUCT),
59+
("/Products?$filter=ModificationDate eq 2022-06-26T06:30:34.558Z and PublicationDate eq 2022-06-26T06:30:34.558Z&$expand=Attributes", PRIP_PRODUCT),
60+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'productConsolidation' and att/OData.CSC.StringAttribute/Value eq 'FULL') and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'instrumentConfigurationID' and att/OData.CSC.StringAttribute/Value eq '7')&$expand=Attributes", PRIP_PRODUCT),
61+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'qualityDataObjectID' and att/OData.CSC.StringAttribute/Value eq 'measurementData') and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'coordinates' and att/OData.CSC.StringAttribute/Value eq '-59.3169 2.6367,-63.105 -14.0539,-60.8506 -14.4245,-57.13092.3269,-59.3169 2.6367')&$expand=Attributes", PRIP_PRODUCT),
62+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'sliceProductFlag' and att/OData.CSC.StringAttribute/Value eq 'False') and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'endingDateTime' and att/OData.CSC.StringAttribute/Value eq '2022-06-26T05:10:38.849Z')&$expand=Attributes", PRIP_PRODUCT),
63+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'beginningDateTime' and att/OData.CSC.StringAttribute/Value eq '2022-06-26T05:05:33.863Z')&$expand=Attributes", PRIP_PRODUCT),
64+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'instrumentShortName' and att/OData.CSC.StringAttribute/Value eq 'SAR') and platformShortName eq 'SENTINEL-1'&$expand=Attributes", PRIP_PRODUCT),
65+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'polarisationChannels' and att/OData.CSC.StringAttribute/Value eq 'HH') and orbitNumber eq 43829&$expand=Attributes", PRIP_PRODUCT),
66+
("/Products?$filter=OData.CSC.Intersects(area=geography'SRID=4326;POLYGON((-60 0,-62 -10,-58 -10,-56 0,-60 0))')&$expand=Attributes", PRIP_PRODUCT),
67+
("/Products?$filter=contains(Name, 'IW_RAW__0NSH') and endswith(Name, 'SAFE.zip')&$expand=Attributes", PRIP_PRODUCT),
68+
("/Products?$filter=startswith(Name, 'S1A_IW') and ContentDate/End eq 2022-06-26T05:10:38.849Z and orbitDirection eq 'ASCENDING'&$expand=Attributes", PRIP_PRODUCT),
69+
("/Products?$filter=cycleNumber eq 265 and productType eq 'IW_RAW__0N' and orbitDirection eq 'ASCENDING'&$expand=Attributes", PRIP_PRODUCT),
70+
#("/Products?$filter=orbitNumber eq 43829 and relativeOrbitNumber eq 43829&$expand=Attributes", PRIP_PRODUCT),
71+
("/Products?$filter=instrumentShortName eq 'SAR' and platformShortName eq 'SENTINEL-1' and platformSerialIdentifier eq 'A'&$expand=Attributes", PRIP_PRODUCT),
72+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'productClass' and att/OData.CSC.StringAttribute/Value eq 'N') and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'productType' and att/OData.CSC.StringAttribute/Value eq 'IW_RAW__0N')&$expand=Attributes", PRIP_PRODUCT),
73+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'platformShortName' and att/OData.CSC.StringAttribute/Value eq 'INVALID')&$expand=Attributes", None),
74+
("/Products?$filter=startswith(Name, 'INVALID')&$expand=Attributes", None),
75+
("/Products?$filter=endswith(Name, 'INVALID')&$expand=Attributes", None),
76+
("/Products?$filter=orbitNumber eq 12345 and platformSerialIdentifier eq 'Z'&$expand=Attributes", None),
77+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'productType' and att/OData.CSC.StringAttribute/Value eq 'INVALID')&$expand=Attributes", None),
78+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'instrumentShortName' and att/OData.CSC.StringAttribute/Value eq 'INVALID') and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'orbitDirection' and att/OData.CSC.StringAttribute/Value eq 'INVALID')&$expand=Attributes", None),
79+
("/Products?$filter=EvictionDate eq 1900-01-01T00:00:00.000Z&$expand=Attributes", None),
80+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'polarisationChannels' and att/OData.CSC.StringAttribute/Value eq 'INVALID')&$expand=Attributes", None),
81+
("/Products?$filter=startswith(Name, 'S1A_IW') and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'datatakeID' and att/OData.CSC.StringAttribute/Value eq '000000')&$expand=Attributes", None),
82+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'coordinates' and att/OData.CSC.StringAttribute/Value eq 'INVALID')&$expand=Attributes", None),
83+
("/Products?$filter=orbitNumber eq 99999 and cycleNumber eq 999&$expand=Attributes", None),
84+
#("/Products?$filter=originDate eq 2000-01-01T00:00:00.000Z&$expand=Attributes", None),
85+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'sliceProductFlag' and att/OData.CSC.StringAttribute/Value eq 'INVALID')&$expand=Attributes", None),
86+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'instrumentConfigurationID' and att/OData.CSC.StringAttribute/Value eq '999')&$expand=Attributes", None),
87+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'startTimeFromAscendingNode' and att/OData.CSC.StringAttribute/Value eq '9999999')&$expand=Attributes", None),
88+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'productClass' and att/OData.CSC.StringAttribute/Value eq 'INVALID')&$expand=Attributes", None),
89+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'platformShortName' and att/OData.CSC.StringAttribute/Value eq 'INVALID') and orbitDirection eq 'INVALID'&$expand=Attributes", None),
90+
("/Products?$filter=startswith(Name, 'S1A_IW') and endswith(Name, 'INVALID')&$expand=Attributes", None),
91+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'processingCenter' and att/OData.CSC.StringAttribute/Value eq 'INVALID') and processingDate eq 2000-01-01T00:00:00.000Z&$expand=Attributes", None),
92+
("/Products?$filter=OData.CSC.Intersects(area=geography'SRID=4326;POLYGON((-80 40,-82 30,-78 30,-76 40,-80 40))')&$expand=Attributes", None),
93+
#("/Products?$filter=contains(Name, 'INVALID') and endswith(Name, 'SAFE.zip')&$expand=Attributes", None),
94+
("/Products?$filter=orbitNumber eq 123 and productType eq 'INVALID' and platformSerialIdentifier eq 'Z'&$expand=Attributes", None),
95+
("/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'orbitDirection' and att/OData.CSC.StringAttribute/Value eq 'INVALID') and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'productConsolidation' and att/OData.CSC.StringAttribute/Value eq 'INVALID')&$expand=Attributes", None),
96+
("/Products?$filter=ContentDate/Start eq 2000-01-01T00:00:00.000Z&$expand=Attributes", None),
97+
98+
99+
])
100+
def test_query_products(prip_client, url, response):
101+
assert prip_client.get(url).status_code == HTTPStatus.OK # Should return all products
102+
assert json.loads(prip_client.get(url).data)["value"] == ([response] if response else [])

0 commit comments

Comments
 (0)