Skip to content

Commit

Permalink
Fix unfeasible tests (#2611)
Browse files Browse the repository at this point in the history
needed for #2606
  • Loading branch information
payetvin authored Feb 6, 2025
1 parent a1b7826 commit a2db7e5
Show file tree
Hide file tree
Showing 3 changed files with 258 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
[submodule "src/tests/resources/Antares_Simulator_Tests_NR"]
path = src/tests/resources/Antares_Simulator_Tests_NR
url = https://github.com/AntaresSimulatorTeam/Antares_Simulator_Tests_NR.git
branch = main
ignore = dirty
2 changes: 1 addition & 1 deletion src/tests/resources/Antares_Simulator_Tests_NR
261 changes: 255 additions & 6 deletions src/tests/run-study-tests/test_unfeasible_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

from fixtures import *

ALL_STUDIES_PATH = Path('../resources/Antares_Simulator_Tests').resolve()
ALL_STUDIES_PATH = Path('../resources/Antares_Simulator_Tests_NR/unfeasible-problem').resolve()

# --------------------------------------------------------------
# Test behavior when an infeasible problem occurs
# --------------------------------------------------------------

@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "specific-tests" / "unfeasible-problem" / "unfeasible_problem_01"], indirect=True)
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_01"], indirect=True)
def test_unfeasible_problem_01__error_verbose(study_path, check_runner):
errors_on_weeks = []
errors_on_weeks.append(weeks_in_year(year=3, weeks=[19]))
Expand All @@ -25,7 +25,7 @@ def test_unfeasible_problem_01__error_verbose(study_path, check_runner):
check_runner.run(checks)

@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "specific-tests" / "unfeasible-problem" / "unfeasible_problem_01"], indirect=True)
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_01"], indirect=True)
def test_unfeasible_problem_01__error_dry(study_path, check_runner):
errors_on_weeks = []
errors_on_weeks.append(weeks_in_year(year=3, weeks=[19]))
Expand All @@ -37,7 +37,7 @@ def test_unfeasible_problem_01__error_dry(study_path, check_runner):
check_runner.run(checks)

@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "specific-tests" / "unfeasible-problem" / "unfeasible_problem_01"], indirect=True)
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_01"], indirect=True)
def test_unfeasible_problem_01__warning_verbose(study_path, check_runner):
warnings_on_weeks = []
warnings_on_weeks.append(weeks_in_year(year=3, weeks=[19]))
Expand All @@ -52,7 +52,7 @@ def test_unfeasible_problem_01__warning_verbose(study_path, check_runner):
check_runner.run(checks)

@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "specific-tests" / "unfeasible-problem" / "unfeasible_problem_01"], indirect=True)
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_01"], indirect=True)
def test_unfeasible_problem_01__warning_dry(study_path, check_runner):
warnings_on_weeks = []
warnings_on_weeks.append(weeks_in_year(year=3, weeks=[19]))
Expand All @@ -64,4 +64,253 @@ def test_unfeasible_problem_01__warning_dry(study_path, check_runner):
checks.add(check = unfeasible_problem(study_path, new_behavior="warning-dry",
checks_on_weeks=warnings_on_weeks,
simulation=check_runner.get_simulation()))
check_runner.run(checks)
check_runner.run(checks)


@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_02"], indirect=True)
def test_unfeasible_problem_02__warning_dry(study_path, check_runner):
warnings_on_weeks = []
warnings_on_weeks.append(weeks_in_year(year=6, weeks=[22,23,29]))

checks = check_list()
checks.add(check = unfeasible_problem(study_path, new_behavior="warning-dry",
checks_on_weeks=warnings_on_weeks,
simulation=check_runner.get_simulation()))
check_runner.run(checks)

@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_02"], indirect=True)
def test_unfeasible_problem_02__error_dry(study_path, check_runner):
errors_on_weeks = []
errors_on_weeks.append(weeks_in_year(year=6, weeks=[22]))

checks = check_list()
checks.add(check = unfeasible_problem(study_path, new_behavior="error-dry",
checks_on_weeks=errors_on_weeks,
simulation=check_runner.get_simulation()))
check_runner.run(checks)


@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_03"], indirect=True)
def test_unfeasible_problem_03__warning_dry(study_path, check_runner):
warnings_on_weeks = []
warnings_on_weeks.append(weeks_in_year(year=3, weeks=[19]))
warnings_on_weeks.append(weeks_in_year(year=6, weeks=[42,43,49]))
warnings_on_weeks.append(weeks_in_year(year=7, weeks=[19]))
warnings_on_weeks.append(weeks_in_year(year=8, weeks=[19]))

checks = check_list()
checks.add(check = unfeasible_problem(study_path, new_behavior="warning-dry",
checks_on_weeks=warnings_on_weeks,
simulation=check_runner.get_simulation()))
check_runner.run(checks)

@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_03"], indirect=True)
def test_unfeasible_problem_03__error_dry(study_path, check_runner):
errors_on_weeks = []
errors_on_weeks.append(weeks_in_year(year=3, weeks=[19]))

checks = check_list()
checks.add(check = unfeasible_problem(study_path, new_behavior="error-dry",
checks_on_weeks=errors_on_weeks,
simulation=check_runner.get_simulation()))
check_runner.run(checks)


@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_04"], indirect=True)
def test_unfeasible_problem_04__warning_dry(study_path, check_runner):
warnings_on_weeks = []
warnings_on_weeks.append(weeks_in_year(year=6, weeks=[22,23,29]))

checks = check_list()
checks.add(check = unfeasible_problem(study_path, new_behavior="warning-dry",
checks_on_weeks=warnings_on_weeks,
simulation=check_runner.get_simulation()))
check_runner.run(checks)

@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_04"], indirect=True)
def test_unfeasible_problem_04__error_dry(study_path, check_runner):
errors_on_weeks = []
errors_on_weeks.append(weeks_in_year(year=6, weeks=[22]))

checks = check_list()
checks.add(check = unfeasible_problem(study_path, new_behavior="error-dry",
checks_on_weeks=errors_on_weeks,
simulation=check_runner.get_simulation()))
check_runner.run(checks)


@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_05"], indirect=True)
def test_unfeasible_problem_05__warning_dry(study_path, check_runner):
warnings_on_weeks = []
warnings_on_weeks.append(weeks_in_year(year=10, weeks=[19]))
warnings_on_weeks.append(weeks_in_year(year=11, weeks=[19]))
warnings_on_weeks.append(weeks_in_year(year=16, weeks=[19]))
warnings_on_weeks.append(weeks_in_year(year=29, weeks=[19]))
warnings_on_weeks.append(weeks_in_year(year=41, weeks=[42,43,49]))
warnings_on_weeks.append(weeks_in_year(year=43, weeks=[42,43,49]))
warnings_on_weeks.append(weeks_in_year(year=46, weeks=[42,43,49]))
warnings_on_weeks.append(weeks_in_year(year=142, weeks=[42,43,49]))

checks = check_list()
checks.add(check = unfeasible_problem(study_path, new_behavior="warning-dry",
checks_on_weeks=warnings_on_weeks,
simulation=check_runner.get_simulation()))
check_runner.run(checks)

@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_05"], indirect=True)
def test_unfeasible_problem_05__error_dry(study_path, check_runner):
errors_on_weeks = []
errors_on_weeks.append(weeks_in_year(year=10, weeks=[19]))

checks = check_list()
checks.add(check = unfeasible_problem(study_path, new_behavior="error-dry",
checks_on_weeks=errors_on_weeks,
simulation=check_runner.get_simulation()))
check_runner.run(checks)


@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_06"], indirect=True)
def test_unfeasible_problem_06__warning_dry(study_path, check_runner):
warnings_on_weeks = []
warnings_on_weeks.append(weeks_in_year(year=3, weeks=[19]))
warnings_on_weeks.append(weeks_in_year(year=6, weeks=[42,43,49]))
warnings_on_weeks.append(weeks_in_year(year=7, weeks=[19]))
warnings_on_weeks.append(weeks_in_year(year=8, weeks=[19]))

checks = check_list()
checks.add(check = unfeasible_problem(study_path, new_behavior="warning-dry",
checks_on_weeks=warnings_on_weeks,
simulation=check_runner.get_simulation()))
check_runner.run(checks)

@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_06"], indirect=True)
def test_unfeasible_problem_06__error_dry(study_path, check_runner):
errors_on_weeks = []
errors_on_weeks.append(weeks_in_year(year=3, weeks=[19]))

checks = check_list()
checks.add(check = unfeasible_problem(study_path, new_behavior="error-dry",
checks_on_weeks=errors_on_weeks,
simulation=check_runner.get_simulation()))
check_runner.run(checks)

@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_07"], indirect=True)
def test_unfeasible_problem_07__warning_dry(study_path, check_runner):
warnings_on_weeks = []
warnings_on_weeks.append(weeks_in_year(year=1, weeks=[1]))
warnings_on_weeks.append(weeks_in_year(year=3, weeks=[52]))
warnings_on_weeks.append(weeks_in_year(year=5, weeks=[1]))
warnings_on_weeks.append(weeks_in_year(year=7, weeks=[52]))
warnings_on_weeks.append(weeks_in_year(year=9, weeks=[52]))

checks = check_list()
checks.add(check = unfeasible_problem(study_path, new_behavior="warning-dry",
checks_on_weeks=warnings_on_weeks,
simulation=check_runner.get_simulation()))
check_runner.run(checks)

@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_07"], indirect=True)
def test_unfeasible_problem_07__error_dry(study_path, check_runner):
errors_on_weeks = []
errors_on_weeks.append(weeks_in_year(year=1, weeks=[1]))

checks = check_list()
checks.add(check = unfeasible_problem(study_path, new_behavior="error-dry",
checks_on_weeks=errors_on_weeks,
simulation=check_runner.get_simulation()))
check_runner.run(checks)


@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_08"], indirect=True)
def test_unfeasible_problem_08__warning_dry(study_path, check_runner):
warnings_on_weeks = []
warnings_on_weeks.append(weeks_in_year(year=3, weeks=[51]))
warnings_on_weeks.append(weeks_in_year(year=7, weeks=[51]))
warnings_on_weeks.append(weeks_in_year(year=9, weeks=[51]))

checks = check_list()
checks.add(check = unfeasible_problem(study_path, new_behavior="warning-dry",
checks_on_weeks=warnings_on_weeks,
simulation=check_runner.get_simulation()))
check_runner.run(checks)

@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_08"], indirect=True)
def test_unfeasible_problem_08__error_dry(study_path, check_runner):
errors_on_weeks = []
errors_on_weeks.append(weeks_in_year(year=3, weeks=[51]))

checks = check_list()
checks.add(check = unfeasible_problem(study_path, new_behavior="error-dry",
checks_on_weeks=errors_on_weeks,
simulation=check_runner.get_simulation()))
check_runner.run(checks)


@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_09"], indirect=True)
def test_unfeasible_problem_09__warning_dry(study_path, check_runner):
warnings_on_weeks = []
warnings_on_weeks.append(weeks_in_year(year=1, weeks=[1]))
warnings_on_weeks.append(weeks_in_year(year=3, weeks=[52]))
warnings_on_weeks.append(weeks_in_year(year=5, weeks=[1]))
warnings_on_weeks.append(weeks_in_year(year=7, weeks=[52]))
warnings_on_weeks.append(weeks_in_year(year=9, weeks=[52]))

checks = check_list()
checks.add(check = unfeasible_problem(study_path, new_behavior="warning-dry",
checks_on_weeks=warnings_on_weeks,
simulation=check_runner.get_simulation()))
check_runner.run(checks)

@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_09"], indirect=True)
def test_unfeasible_problem_09__error_dry(study_path, check_runner):
errors_on_weeks = []
errors_on_weeks.append(weeks_in_year(year=1, weeks=[1]))

checks = check_list()
checks.add(check = unfeasible_problem(study_path, new_behavior="error-dry",
checks_on_weeks=errors_on_weeks,
simulation=check_runner.get_simulation()))
check_runner.run(checks)


@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_10"], indirect=True)
def test_unfeasible_problem_10__warning_dry(study_path, check_runner):
warnings_on_weeks = []
warnings_on_weeks.append(weeks_in_year(year=3, weeks=[51]))
warnings_on_weeks.append(weeks_in_year(year=7, weeks=[51]))
warnings_on_weeks.append(weeks_in_year(year=9, weeks=[51]))

checks = check_list()
checks.add(check = unfeasible_problem(study_path, new_behavior="warning-dry",
checks_on_weeks=warnings_on_weeks,
simulation=check_runner.get_simulation()))
check_runner.run(checks)

@pytest.mark.unfeasible
@pytest.mark.parametrize('study_path', [ALL_STUDIES_PATH / "unfeasible_problem_10"], indirect=True)
def test_unfeasible_problem_10__error_dry(study_path, check_runner):
errors_on_weeks = []
errors_on_weeks.append(weeks_in_year(year=3, weeks=[51]))

checks = check_list()
checks.add(check = unfeasible_problem(study_path, new_behavior="error-dry",
checks_on_weeks=errors_on_weeks,
simulation=check_runner.get_simulation()))
check_runner.run(checks)

0 comments on commit a2db7e5

Please sign in to comment.