Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,4 @@ dmypy.json
# Development
.idea/
build/
.vscode
6 changes: 6 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ docker pull qgis/qgis:release-3_16
docker pull qgis/qgis:release-3_22
```

Run the following command in linux shell to ensure the build directory exists and includes test files.

```
poetry run python admin.py build --tests
```

```
./run-tests.sh
```
Expand Down
1,354 changes: 849 additions & 505 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mkdocs-material = "^8.1.4"
mkdocs-git-revision-date-localized-plugin = "^0.11.1"
mkdocs-video = "^1.1.0"
python = "^3.8"
httpx = "^0.20.0"
httpx = "^0.28.1"
toml = "^0.10.2"
typer = "^0.4.0"

Expand Down
9 changes: 8 additions & 1 deletion run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ QGIS_VERSION_TAGS=($QGIS_IMAGE_V_3_16 $QGIS_IMAGE_V_3_20)

export IMAGE=$QGIS_IMAGE

exit_code=0
for TAG in "${QGIS_VERSION_TAGS[@]}"
do
echo "Running tests for QGIS $TAG"
Expand All @@ -23,6 +24,12 @@ do
docker-compose exec -T qgis-testing-environment sh -c "pip3 install flask"

docker-compose exec -T qgis-testing-environment qgis_testrunner.sh test_suite.test_package
exit_code=$?
docker-compose down

if [ $exit_code -ne 0 ]; then
echo "exiting early"
break
fi
done

exit $exit_code
25 changes: 19 additions & 6 deletions test/mock/mock_http_server.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import os
import requests
import socket

import multiprocessing

from flask import jsonify, request
from flask import request
from threading import Thread
from time import sleep, time
from typing import Final

from .stac_api_server_app import app
from .stac_api_auth_server_app import app as auth_app


_host: Final[str] = "localhost"
_default_port: Final[int] = 5000

class MockSTACApiServer(Thread):
""" Mock a live """
def __init__(self, port=5000, auth=False):
def __init__(self, port=_default_port, auth=False):
super().__init__()
self.port = port

Expand All @@ -21,7 +24,7 @@ def __init__(self, port=5000, auth=False):
else:
self.app = auth_app

self.url = "http://localhost:%s" % self.port
self.url = "http://%s:%s" % (_host, self.port)

try:
self.app.add_url_rule("/shutdown", view_func=self._shutdown_server)
Expand All @@ -40,3 +43,13 @@ def shutdown_server(self):

def run(self):
self.app.run(port=self.port)

def wait_for_ready(self, wait_timeout_seconds: int = 5) -> None:
start = time()
while time() - start < wait_timeout_seconds:
try:
socket.create_connection((_host, self.port), timeout=1)
return
except (ConnectionRefusedError, OSError):
sleep(1)
raise Exception("Unable to establish a connection to server at %s:%s in %ss" % (_host, self.port, wait_timeout_seconds))
1 change: 1 addition & 0 deletions test/test_stac_api_client_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def setUp(self):

self.server = Process(target=self.app_server.run)
self.server.start()
self.app_server.wait_for_ready()

self.api_client = Client(self.app_server.url)
self.response = None
Expand Down
1 change: 1 addition & 0 deletions test/test_stac_api_client_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def setUp(self):

self.server = Process(target=self.app_server.run)
self.server.start()
self.app_server.wait_for_ready()

self.api_client = Client(self.app_server.url)
self.response = None
Expand Down