From e2dd58ad541e3cefcebe6f6538650b54143cb159 Mon Sep 17 00:00:00 2001 From: cgl Date: Wed, 7 Aug 2024 15:32:06 +0200 Subject: [PATCH] Ajoute test pote dans la CI --- .gitignore | 3 +++ .gitlab-ci.yml | 10 ++++++++++ .../pote_openfisca_survey_manager_config.ini | 15 +++++++++++++++ tests/pote/create_fake_data.py | 2 -- tests/pote/test_pote_survey_scenario.py | 6 ++++++ 5 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 .gitlab-ci/pote_openfisca_survey_manager_config.ini create mode 100644 tests/pote/test_pote_survey_scenario.py diff --git a/.gitignore b/.gitignore index c094274a..6e4fe65c 100644 --- a/.gitignore +++ b/.gitignore @@ -89,3 +89,6 @@ openfisca_erfs_fpr.json .pytest_cache/ figures_directory + +# test python +*.parquet diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bec7f94f..abfd37ed 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,6 +17,7 @@ cache: stages: - docker - test + - pote - build_collection - build_input_data - diagnostics @@ -133,6 +134,15 @@ diagnostics: tags: - openfisca +build_and_test_pote: + image: $CI_REGISTRY_IMAGE:latest + script: + - cp ./.gitlab-ci/pote_openfisca_survey_manager_config.ini ~/.config/openfisca-survey-manager/config.ini + - python tests/pote/create_fake_data.py -y 2022 -p /tests/pote/fake_data/raw/ + - build-pote -y 2022 -c ~/.config/openfisca-survey-manager/ + - pytest tests/pote/test_pote_survey_scenario + stage: pote + check-version-and-changelog: stage: diagnostics before_script: diff --git a/.gitlab-ci/pote_openfisca_survey_manager_config.ini b/.gitlab-ci/pote_openfisca_survey_manager_config.ini new file mode 100644 index 00000000..040e1eb2 --- /dev/null +++ b/.gitlab-ci/pote_openfisca_survey_manager_config.ini @@ -0,0 +1,15 @@ +# Version pote du emplate du fichier config.ini de openfisca-survey-manager +# pour qu'il fonctionne avec openfisca-france-data + + +[collections] +collections_directory = /tests/pote/fake_data/output/data_collections +pote = /tests/pote/fake_data/output/data_collections/pote.json + +[data] +raw_pote = /tests/pote/fake_data/raw/ +output_directory = /tests/pote/fake_data/output/ +tmp_directory = /tests/pote/fake_data/tmp/ + +[openfisca_france_data_pote] +errors_path = /tests/pote/fake_data/ diff --git a/tests/pote/create_fake_data.py b/tests/pote/create_fake_data.py index 47abbf24..91dd6a92 100644 --- a/tests/pote/create_fake_data.py +++ b/tests/pote/create_fake_data.py @@ -5,8 +5,6 @@ import os import click -output_path = "/home/cgl/leximpact/openfisca-france-data/tests/pote/fake_data/raw/" - def create_fake_data(year = 2022, data_length = 100, output_path = output_path): if not os.path.exists(output_path): os.makedirs(output_path) diff --git a/tests/pote/test_pote_survey_scenario.py b/tests/pote/test_pote_survey_scenario.py new file mode 100644 index 00000000..f303ad1a --- /dev/null +++ b/tests/pote/test_pote_survey_scenario.py @@ -0,0 +1,6 @@ +from openfisca_france_data.pote.survey_scenario import PoteSurveyScenario +from openfisca_survey_manager import default_config_files_directory + +def test_pote_survey_scenario(period, config_file_directory=default_config_files_directory): + survey_scenario = PoteSurveyScenario(period = period, config_files_directory=config_file_directory) + assert survey_scenario.simulations['baseline'].compute_aggregate('irpp_economique', period) < 0, "La simulation ne s'est pas bien passée"