Skip to content

Commit

Permalink
Merge pull request #74 from EURODEO/smoke-test
Browse files Browse the repository at this point in the history
Add Smoke/Integration tests for the EDR API
  • Loading branch information
Jeffrey-Vervoort-KNMI authored Dec 4, 2023
2 parents d23b618 + 327aa1e commit de3b141
Show file tree
Hide file tree
Showing 15 changed files with 899 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.run/

# Python
.pytest_cache/
__pycache__/
venv/

Expand Down
3 changes: 2 additions & 1 deletion api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ def get_datetime_range(datetime_string: str | None) -> Tuple[Timestamp, Timestam
else:
start_datetime.FromDatetime(datetime.min)
if datetimes[1] != "..":
end_datetime.FromDatetime(aware_datetime_type_adapter.validate_python(datetimes[1]))
# HACK add one second so that the end_datetime is included in the interval.
end_datetime.FromDatetime(aware_datetime_type_adapter.validate_python(datetimes[1]) + timedelta(seconds=1))
else:
end_datetime.FromDatetime(datetime.max)

Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ services:
condition: service_healthy

api:
hostname: api
build:
context: . # TODO: Needed to get proto file. Find a better solution
dockerfile: api/Dockerfile
Expand Down Expand Up @@ -93,6 +94,7 @@ services:
environment:
- DSHOST=store
- DSPORT=50050
- BASE_URL=http://api:8000
depends_on:
store:
condition: service_healthy
Expand Down
3 changes: 3 additions & 0 deletions integration-test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ RUN python -m grpc_tools.protoc \

COPY "${PROJECT_PYTHON_PATH}/test_knmi.py" "${DOCKER_PATH}/test_knmi.py"
COPY "${PROJECT_PYTHON_PATH}/test_delete.py" "${DOCKER_PATH}/test_delete.py"
COPY "${PROJECT_PYTHON_PATH}/test_api.py" "${DOCKER_PATH}/test_api.py"

COPY "${PROJECT_PYTHON_PATH}/response/" "${DOCKER_PATH}/response/"

WORKDIR "${DOCKER_PATH}"
CMD ["pytest"]
2 changes: 2 additions & 0 deletions integration-test/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
# Install using:
# pip-sync

deepdiff~=6.2
grpcio-tools~=1.56
pytest~=7.4
requests~=2.31
24 changes: 19 additions & 5 deletions integration-test/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,34 @@
#
# pip-compile --no-emit-index-url
#
grpcio==1.58.0
certifi==2023.11.17
# via requests
charset-normalizer==3.3.2
# via requests
deepdiff==6.7.1
# via -r requirements.in
grpcio==1.59.3
# via grpcio-tools
grpcio-tools==1.58.0
grpcio-tools==1.59.3
# via -r requirements.in
idna==3.6
# via requests
iniconfig==2.0.0
# via pytest
packaging==23.1
ordered-set==4.1.0
# via deepdiff
packaging==23.2
# via pytest
pluggy==1.3.0
# via pytest
protobuf==4.24.3
protobuf==4.25.1
# via grpcio-tools
pytest==7.4.2
pytest==7.4.3
# via -r requirements.in
requests==2.31.0
# via -r requirements.in
urllib3==2.1.0
# via requests

# The following packages are considered to be unsafe in a requirements file:
# setuptools
77 changes: 77 additions & 0 deletions integration-test/response/capabilities/200/all_collections.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"links": [
{
"href": "http://localhost:8008/collections",
"rel": "self"
}
],
"collections": [
{
"id": "observations",
"links": [
{
"href": "http://localhost:8008/collections/observations",
"rel": "self"
}
],
"extent": {
"spatial": {
"bbox": [
[
3.0,
50.0,
8.0,
55.0
]
],
"crs": "WGS84"
}
},
"data_queries": {
"position": {
"link": {
"href": "http://localhost:8008/collections/observations/position",
"rel": "data",
"variables": {
"query_type": "position",
"output_format": [
"CoverageJSON"
]
}
}
},
"area": {
"link": {
"href": "http://localhost:8008/collections/observations/area",
"rel": "data",
"variables": {
"query_type": "area",
"output_format": [
"CoverageJSON"
]
}
}
},
"locations": {
"link": {
"href": "http://localhost:8008/collections/observations/locations",
"rel": "data",
"variables": {
"query_type": "locations",
"output_format": [
"CoverageJSON"
]
}
}
}
},
"crs": [
"WGS84"
],
"output_formats": [
"CoverageJSON"
],
"parameter_names": {}
}
]
}
Loading

0 comments on commit de3b141

Please sign in to comment.