Skip to content

Commit

Permalink
chore: move drogon case to libecalc and include it in test framework
Browse files Browse the repository at this point in the history
  • Loading branch information
kjbrak committed Dec 13, 2024
1 parent ba83e5b commit 58fa167
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 10 deletions.
8 changes: 4 additions & 4 deletions docs/docs/about/modelling/examples/drogon.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import CodeLinesFromFile from "../../../../src/components/CodeLinesFromFile";
import CodeBlock from '@theme/CodeBlock';
import yamlModel from '!!raw-loader!./drogon/model.yaml';
import genset from '!!raw-loader!./drogon/genset.csv';
import wi200barSSP from '!!raw-loader!./drogon/wi_200bar_ssp.csv';
import drogonMean from '!!raw-loader!./drogon/drogon_mean.csv';
import yamlModel from '!!raw-loader!@examples/drogon/model.yaml';
import genset from '!!raw-loader!@examples/drogon/genset.csv';
import wi200barSSP from '!!raw-loader!@examples/drogon/wi_200bar_ssp.csv';
import drogonMean from '!!raw-loader!@examples/drogon/drogon_mean.csv';

# Drogon model example

Expand Down
1 change: 1 addition & 0 deletions src/libecalc/examples/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .advanced import * # noqa: F403
from .drogon import * # noqa: F403
from .simple import * # noqa: F403
27 changes: 27 additions & 0 deletions src/libecalc/examples/drogon/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from pathlib import Path

import pytest

from libecalc.fixtures import YamlCase
from libecalc.fixtures.case_utils import YamlCaseLoader

"""
Test project for Drogon (synthetic test case used for various purposes outside this project)
The purpose of this fixture is to showcase the synthetic model Drogon in an eCalc Model for use with
examples and testing.
"""


@pytest.fixture
def drogon_yaml() -> YamlCase:
return YamlCaseLoader.load(
case_path=Path(__file__).parent,
main_file="model.yaml",
resource_names=[
"drogon_mean.csv",
"genset.csv",
"wi_200bar_ssp.csv",
],
)
File renamed without changes.
File renamed without changes.
15 changes: 9 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@

from libecalc.common.math.numbers import Numbers
from libecalc.common.time_utils import Frequency
from libecalc.examples import advanced, simple
from libecalc.examples import advanced, drogon, simple
from libecalc.fixtures import YamlCase
from libecalc.fixtures.cases import (
all_energy_usage_models,
consumer_system_v2,
ltp_export,
)
from libecalc.fixtures.cases import all_energy_usage_models, consumer_system_v2, ltp_export
from libecalc.presentation.yaml.configuration_service import ConfigurationService
from libecalc.presentation.yaml.model import YamlModel
from libecalc.presentation.yaml.resource_service import ResourceService
Expand Down Expand Up @@ -56,6 +52,7 @@ def rounded_snapshot(data: dict, snapshot_name: str):
"simple": (Path(simple.__file__).parent / "model.yaml").absolute(),
"simple_temporal": (Path(simple.__file__).parent / "model_temporal.yaml").absolute(),
"advanced": (Path(advanced.__file__).parent / "model.yaml").absolute(),
"drogon": (Path(drogon.__file__).parent / "model.yaml").absolute(),
"ltp": (Path(ltp_export.__file__).parent / "data" / "ltp_export.yaml").absolute(),
"all_energy_usage_models": (
Path(all_energy_usage_models.__file__).parent / "data" / "all_energy_usage_models.yaml"
Expand All @@ -68,6 +65,7 @@ def rounded_snapshot(data: dict, snapshot_name: str):
"simple": "simple_yaml",
"simple_temporal": "simple_temporal_yaml",
"advanced": "advanced_yaml",
"drogon": "drogon_yaml",
"ltp": "ltp_export_yaml",
"all_energy_usage_models": "all_energy_usage_models_yaml",
"consumer_system_v2": "consumer_system_v2_yaml",
Expand Down Expand Up @@ -100,6 +98,11 @@ def advanced_yaml_path():
return valid_example_cases["advanced"]


@pytest.fixture(scope="session")
def drogon_yaml_path():
return valid_example_cases["drogon"]


@pytest.fixture
def ltp_yaml_path():
return valid_example_cases["ltp"]
Expand Down

0 comments on commit 58fa167

Please sign in to comment.