-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce tests and CI for testing
Co-authored-by: Jakob Schnell <Jakob.Schnell@heigit.org>
- Loading branch information
Showing
15 changed files
with
1,169 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
name: Testing | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
test_3_16: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run test 3.16 | ||
run: | | ||
docker run -v ${GITHUB_WORKSPACE}:/src -w /src qgis/qgis:release-3_16 sh -c 'apt-get -y update && apt-get -y install xvfb && export ORS_API_KEY=${{ secrets.ORS_API_KEY }} && export DISPLAY=:0.0 && pip install -U pytest && xvfb-run pytest' | ||
env: | ||
DOCKER_IMAGE: ${{ steps.docker-build.outputs.FULL_IMAGE_NAME }} | ||
test_3_22: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run test 3.22 | ||
run: | | ||
docker run -v ${GITHUB_WORKSPACE}:/src -w /src qgis/qgis:release-3_22 sh -c 'apt-get -y update && apt-get -y install xvfb && export DISPLAY=:0.0 && export ORS_API_KEY=${{ secrets.ORS_API_KEY }} && export DISPLAY=:0.0 && pip install -U pytest && xvfb-run pytest' | ||
env: | ||
DOCKER_IMAGE: ${{ steps.docker-build.outputs.FULL_IMAGE_NAME }} | ||
test_latest: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run test latest | ||
run: | | ||
docker run -v ${GITHUB_WORKSPACE}:/src -w /src qgis/qgis:latest sh -c 'apt-get -y update && apt-get -y install xvfb && export DISPLAY=:0.0 && export ORS_API_KEY=${{ secrets.ORS_API_KEY }} && apt install python3-pytest && xvfb-run pytest' | ||
env: | ||
DOCKER_IMAGE: ${{ steps.docker-build.outputs.FULL_IMAGE_NAME }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
# developement | ||
ruff | ||
pytest | ||
|
||
# testing | ||
pyyaml | ||
pytest |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
import yaml | ||
|
||
from ORStools.utils.configmanager import read_config | ||
|
||
with open("ORStools/config.yml", "r+") as file: | ||
data = yaml.safe_load(file) | ||
|
||
|
||
def pytest_sessionstart(session): | ||
""" | ||
Called after the Session object has been created and | ||
before performing collection and entering the run test loop. | ||
""" | ||
if data["providers"][0]["key"] == "": | ||
data["providers"][0]["key"] = os.environ.get("ORS_API_KEY") | ||
with open("ORStools/config.yml", "w") as file: | ||
yaml.dump(data, file) | ||
else: | ||
raise ValueError("API key is not empty.") | ||
|
||
|
||
def pytest_sessionfinish(session, exitstatus): | ||
""" | ||
Called after whole test run finished, right before | ||
returning the exit status to the system. | ||
""" | ||
with open("ORStools/config.yml", "w") as file: | ||
if not data["providers"][0]["key"] == "": | ||
data['providers'][0]['key'] = '' # fmt: skip | ||
yaml.dump(data, file) | ||
|
||
config = read_config() | ||
assert config["providers"][0]["key"] == '' # fmt: skip |
Oops, something went wrong.