Skip to content

Commit

Permalink
Merge pull request #753 from MTES-MCT/feat-airflow-unit-test
Browse files Browse the repository at this point in the history
Ajout de tests unitaires à airflow
  • Loading branch information
alexisig authored Nov 24, 2024
2 parents 22cad98 + c98b7cc commit 67a9963
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,11 @@ jobs:
- run: pipenv run python -Wa manage.py test
env:
DATABASE_URL: ${{ steps.pg.outputs.connection-uri }}
test-airflow:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: curl -sSL install.astronomer.io | sudo bash -s
- run: cd airflow
- run: astro dev pytest
working-directory: airflow
21 changes: 21 additions & 0 deletions airflow/tests/test_ocsge_source_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import json


def test_ocsge_source_json_is_properly_formatted():
file_path = "include/ocsge/sources.json"
data: dict = json.load(open(file_path))

for source in data.values():
assert isinstance(source, dict)
source_keys = source.keys()
assert "difference" in source_keys
assert "occupation_du_sol_et_zone_construite" in source_keys

# Récupérer les années (ex: 2019, 2022)
occupation_du_sol_et_zone_construite_keys = source["occupation_du_sol_et_zone_construite"].keys()

# Vérifie que la différence est présente pour chaque duo d'année
# TODO : mettre à jour cette logique lorsqu'il y aura plus de 2 années
expected_difference_key = "_".join(sorted(occupation_du_sol_et_zone_construite_keys))

assert expected_difference_key in source["difference"].keys()

0 comments on commit 67a9963

Please sign in to comment.