Skip to content

Commit

Permalink
Restructure test process to test pp integration in another environment.
Browse files Browse the repository at this point in the history
  • Loading branch information
rcschrg committed Nov 15, 2024
1 parent af52570 commit ea7756a
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 8 deletions.
41 changes: 39 additions & 2 deletions .github/workflows/test-monee.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ jobs:
- name: Test+Coverage
run: |
source venv/bin/activate
coverage run -m pytest
coverage report
pytest --cov --cov-report=xml -v -m "not pptest"
build-linux:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -85,6 +84,44 @@ jobs:
run: |
source venv/bin/activate
make -C docs doctest
- name: Test+Coverage
run: |
source venv/bin/activate
pytest --cov --cov-report=xml -v -m "not pptest"
test-pp:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: '**/setup.py'
- name: Install dependencies
run: |
pip install virtualenv
virtualenv venv
source venv/bin/activate
pip3 install -U sphinx
pip3 install -r docs/requirements.txt
pip3 install -e .[testpp]
pip3 install pytest coverage ruff
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
source venv/bin/activate
ruff check .
ruff format --check .
- name: Doctests
run: |
source venv/bin/activate
make -C docs doctest
- name: Test+Coverage
run: |
source venv/bin/activate
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ simbench = [
"pandapower>=2.9.0"
]
test = [
"pytest",
"pytest-cov",
"pre-commit",
]
testpp = [
"pytest",
"peext",
"simbench",
Expand Down
9 changes: 6 additions & 3 deletions tests/io/test_from_pandapower.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import simbench

from monee.io.from_pandapower import from_pandapower_net
import pytest


@pytest.mark.pptest
def test_from_pandapower_net():
import simbench

from monee.io.from_pandapower import from_pandapower_net

# GIVEN
net = simbench.get_simbench_net("1-LV-rural3--1-no_sw")

Expand Down
5 changes: 4 additions & 1 deletion tests/io/test_from_simbench.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from monee.io.from_simbench import obtain_simbench_profile
import pytest


@pytest.mark.pptest
def test_obtain_simbench_profile():
from monee.io.from_simbench import obtain_simbench_profile

# GIVEN WHEN
td = obtain_simbench_profile("1-LV-rural3--1-no_sw")

Expand Down
11 changes: 9 additions & 2 deletions tests/io/test_matpower.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import os

import pandapower.converter as pc
from peext.scenario.network import create_small_test_multinet
import pytest

from monee.io.matpower import read_matpower_case
from monee.solver.gekko import GEKKOSolver


@pytest.mark.pptest
def test_read_network_data_matpower():
import pandapower.converter as pc
from peext.scenario.network import create_small_test_multinet

try:
multinet = create_small_test_multinet()
power = multinet["nets"]["power"]
Expand All @@ -23,7 +26,11 @@ def test_read_network_data_matpower():
os.remove("a.mat")


@pytest.mark.pptest
def test_solve_read_network_data_matpower():
import pandapower.converter as pc
from peext.scenario.network import create_small_test_multinet

try:
multinet = create_small_test_multinet()
power = multinet["nets"]["power"]
Expand Down

0 comments on commit ea7756a

Please sign in to comment.