Skip to content

Reorganize tests #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 0 additions & 67 deletions tests/data/libs/lib_1.yml

This file was deleted.

50 changes: 0 additions & 50 deletions tests/data/libs/lib_2.yml

This file was deleted.

3 changes: 0 additions & 3 deletions tests/data/series/demand-ts.txt

This file was deleted.

73 changes: 0 additions & 73 deletions tests/data/systems/components.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,40 @@

import pytest

from andromede.model.parsing import parse_yaml_library
from andromede.model.parsing import InputLibrary, parse_yaml_library
from andromede.model.resolve_library import Library, resolve_library
from andromede.study.parsing import InputSystem, parse_yaml_components


@pytest.fixture(scope="session")
def libs_dir() -> Path:
return Path(__file__).parents[2] / "data/libs"
return Path(__file__).parent / "libs"


@pytest.fixture
def systems_dir() -> Path:
return Path(__file__).parent / "systems"


@pytest.fixture
def series_dir() -> Path:
return Path(__file__).parent / "series"


@pytest.fixture
def input_system(systems_dir: Path) -> InputSystem:
compo_file = systems_dir / "system.yml"

with compo_file.open() as c:
return parse_yaml_components(c)


@pytest.fixture
def input_library(libs_dir: Path) -> InputLibrary:
library = libs_dir / "lib_unittest.yml"

with library.open() as lib:
return parse_yaml_library(lib)


@pytest.fixture(scope="session")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#
# This file is part of the Antares project.

"""
This file tests that the modeller is able to generate investment problems problems as a single LP problem. Look at `integration/test_benders_decomposed.py` for the generation of decomposed forms of the problem
"""

import pandas as pd
import pytest

Expand Down Expand Up @@ -42,7 +46,7 @@
TimeScenarioSeriesData,
create_component,
)
from tests.data.libs.standard import (
from tests.e2e.functional.libs.standard import (
BALANCE_PORT_TYPE,
CONSTANT,
DEMAND_MODEL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
)
from andromede.study.data import ConstantData, DataBase, TreeData
from andromede.study.network import Component, Network, Node, PortRef, create_component
from tests.data.libs.standard import (
from tests.e2e.functional.libs.standard import (
DEMAND_MODEL,
GENERATOR_MODEL,
NODE_WITH_SPILL_AND_ENS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@
#
# This file is part of the Antares project.

"""
This module contains end-to-end functional tests for systems built by:
- Using Python models,
- Building the network object in Python.

Several cases are tested:

1. **Basic Balance**:
- Description: Balance on a single node with fixed demand and generation.
- Name: `test_basic_balance`.

2. **Time Series Data**:
- Description: Multiple timesteps with varying demand.
- Name: `test_timeseries`.

3. **Variable Bounds**:
- Description: Generator models with variable bounds, including feasibility and infeasibility cases.
- Name: `test_variable_bound`.

4. **Short-Term Storage**:
- Description: Short-term storage behavior over different horizons and efficiencies.
- Names: `test_short_test_horizon_10`, `test_short_test_horizon_5`.
"""
import pandas as pd
import pytest

Expand All @@ -28,7 +51,7 @@
TimeScenarioSeriesData,
create_component,
)
from tests.data.libs.standard import (
from tests.e2e.functional.libs.standard import (
BALANCE_PORT_TYPE,
DEMAND_MODEL,
GENERATOR_MODEL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
# Copyright (c) 2024, RTE (https://www.rte-france.com)
#
# See AUTHORS.txt
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# SPDX-License-Identifier: MPL-2.0
#
# This file is part of the Antares project.

"""
This module contains end-to-end functional tests for systems built by:
- Reading the model library from a YAML file,
- Building the network objet directly in Python.

The tests validate various scenarios involving energy balance, generation, spillage, and demand across nodes and networks.

Tests included:
1. `test_basic_balance`: Verifies energy balance on a single node with fixed demand and generation for one timestep.
2. `test_link`: Tests energy balance across two nodes connected by a link with fixed demand and generation for one timestep.
3. `test_stacking_generation`: Validates energy balance on a single node with fixed demand and two generators having different costs for one timestep.
4. `test_spillage`: Ensures proper handling of spillage when generation exceeds demand on a single node for one timestep.
5. `test_min_up_down_times`: Simulates a scenario with minimum up/down times for a thermal generator over three timesteps, ensuring constraints are satisfied.
6. `test_changing_demand`: Tests energy balance on a single node with changing demand over three timesteps.
7. `test_min_up_down_times_2`: Similar to `test_min_up_down_times`, but with different minimum up/down time constraints for a thermal generator over three timesteps.

Each test builds a network of nodes and components, defines a database of
parameters, and solves the problem. Assertions are made to ensure the solver's results meet expected outcomes.
"""

import pandas as pd
import pytest

Expand All @@ -18,29 +50,7 @@
create_component,
)


def test_network(lib_dict: dict[str, Library]) -> None:
network = Network("test")
assert network.id == "test"
assert list(network.nodes) == []
assert list(network.components) == []
assert list(network.all_components) == []
assert list(network.connections) == []

with pytest.raises(KeyError):
network.get_node("N")

node_model = lib_dict["basic"].models["node"]

N1 = Node(model=node_model, id="N1")
N2 = Node(model=node_model, id="N2")
network.add_node(N1)
network.add_node(N2)
assert list(network.nodes) == [N1, N2]
assert network.get_node(N1.id) == N1
assert network.get_component("N1") == Node(model=node_model, id="N1")
with pytest.raises(KeyError):
network.get_component("unknown")
# TODO : Use fixtures for models and components used several times to simplify this test file


def test_basic_balance(lib_dict: dict[str, Library]) -> None:
Expand Down
Loading
Loading