Skip to content

Commit

Permalink
update modeler cucumber tests
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Feb 17, 2025
1 parent d82c618 commit 72e64ea
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ Feature: 2.5 - Pure modeler simple studies, with no ports and no timeseries
Scenario: 2.5.1: One model with one load and two generators, one timestep
Given the study path is "modeler/epic2/us2.5/study_2.5.1"
When I run antares modeler
Then the simulation succeeds
Then the modeler simulation succeeds
And the objective value is 160
And the optimal value of variable node1.gen1_p_0 is 80
And the optimal value of variable node1.gen2_p_0 is 20

Scenario: 2.5.2: One model with one load and two generators (minP), three timesteps
Given the study path is "modeler/epic2/us2.5/study_2.5.2"
When I run antares modeler
Then the simulation succeeds
Then the modeler simulation succeeds
And the objective value is 810
And the optimal values of the variables are
| component | variable | timestep | value |
Expand All @@ -23,7 +23,7 @@ Feature: 2.5 - Pure modeler simple studies, with no ports and no timeseries
Scenario: 2.5.3: Two libs, one timestep
Given the study path is "modeler/epic2/us2.5/study_2.5.3"
When I run antares modeler
Then the simulation succeeds
Then the modeler simulation succeeds
And the objective value is 15600
And the optimal values of the variables are
| component | variable | timestep | value |
Expand All @@ -37,7 +37,7 @@ Feature: 2.5 - Pure modeler simple studies, with no ports and no timeseries
Scenario: 2.5.4: Test with integer variable
Given the study path is "modeler/epic2/us2.5/study_2.5.4"
When I run antares modeler
Then the simulation succeeds
Then the modeler simulation succeeds
And the objective value is 540
And the optimal value of variable node1.gen_total_p_0 is 1000
And the optimal value of variable node1.gen_n_on_0 is 4
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ Feature: 2.8
Scenario: 2.8.1: One model with one load and two generators, one timestep
Given the study path is "modeler/1_1"
When I run antares modeler
Then the simulation succeeds
Then the modeler simulation succeeds
And the objective value is 160
And the optimal value of variable node1.gen1_p_0 is 80
And the optimal value of variable node1.gen2_p_0 is 20

Scenario: 2.8.1: One model with one load and two generators, mix of constant and time dependent parameter, one timestep.
Given the study path is "modeler/1_2"
When I run antares modeler
Then the simulation succeeds
Then the modeler simulation succeeds
And the objective value is 160
And the optimal value of variable node1.gen1_p_0 is 80
And the optimal value of variable node1.gen2_p_0 is 20
Expand All @@ -24,9 +24,9 @@ Feature: 2.8
Scenario: 2.8.1: Mixture of constant parameters and time series (2 time steps), With booleans type.
Given the study path is "modeler/1_4"
When I run antares modeler
Then the simulation succeeds
Then the modeler simulation succeeds
And the objective value is 765
And the optimal values of the variables are
| component | variable | timestep | value |
| node1 | gen1_p | 0-1 | 80-0 |
| node1 | gen2_p | 0-2 | 20-100 |
| node1 | gen2_p | 0-1 | 20-100 |
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
import subprocess
import os

from common_steps.modeler_output_handler import modeler_output_handler


def run_modeler(context):
command = build_antares_modeler_command(context)
print(f"Running command: {command}")
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
out, err = process.communicate()
context.output_path = os.path.join( context.study_path , "output") # TODO : fixme parse_output_folder_from_logs(out)
context.return_code = process.returncode
context.moh = modeler_output_handler(context.output_path)


def build_antares_modeler_command(context):
Expand Down
11 changes: 11 additions & 0 deletions src/tests/cucumber/features/steps/common_steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from common_steps.simulator_utils import run_simulation

from features.steps.common_steps.assertions import assert_double_close
from common_steps.modeler_output_handler import modeler_output_handler



@given('the study path is "{string}"')
Expand All @@ -34,6 +36,14 @@ def simu_success(context):
assert context.return_code == 0


@then('the modeler simulation succeeds')
def simu_success(context):
assert context.return_code == 0
context.output_path = os.path.join(context.study_path, "output") # TODO : fixme parse_output_folder_from_logs(out)
context.moh = modeler_output_handler(context.output_path)



@then('the simulation fails')
def simu_success(context):
assert context.return_code != 0
Expand Down Expand Up @@ -155,6 +165,7 @@ def get_value(row, ts):

if "-" in ret and not ret.isdigit(): # Handle "80-0" but not single numbers
ret = ret.split("-") # Split into a list of strings
print(f" ret = {ret} , ts = {ts}")
return float(ret[ts]) # Index and convert to float

return float(ret) # Single value case (apply to all timesteps)

0 comments on commit 72e64ea

Please sign in to comment.