-
Notifications
You must be signed in to change notification settings - Fork 1
Add CI testing for pypsa2smspp package integration #53
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
419669c
4b23b04
41ac107
f4c23e1
cb80a74
20e58a4
8d52bc9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,47 @@ jobs: | |
| run: | | ||
| pytest | ||
|
|
||
| test_pypsa2smspp: | ||
| # Test pypsa2smspp package integration | ||
| name: Test pypsa2smspp integration | ||
| needs: | ||
| - test | ||
| runs-on: ${{ matrix.os }} | ||
| permissions: | ||
| contents: read | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| python-version: | ||
| - "3.13" | ||
| - "3.12" | ||
| os: | ||
| - ubuntu-latest | ||
| env: | ||
| MPLBACKEND: Agg # https://github.com/orgs/community/discussions/26434 | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 0 # Needed for setuptools_scm | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Install package and dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install .[dev] | ||
|
|
||
| - name: Install pypsa2smspp | ||
| run: | | ||
| pip install pypsa2smspp | ||
|
|
||
| - name: Test pypsa2smspp integration | ||
| run: | | ||
| pytest test/test_pypsa2smspp.py -v | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want to execute pytest on pypsa2smspp package using the pysmspp package being tested
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated in commit cb80a74. The CI now clones the pypsa2smspp repository and runs its full test suite, which will use the pysmspp package being tested from the current PR. |
||
|
|
||
| test_with_smspp: | ||
| # Test package build in matrix of OS and Python versions | ||
| name: Test package with SMSpp | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| """Tests for pypsa2smspp package integration.""" | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| def test_pypsa2smspp_import(): | ||
| """Test that pypsa2smspp can be imported.""" | ||
| import pypsa2smspp | ||
|
|
||
| assert hasattr(pypsa2smspp, "Transformation") | ||
| assert hasattr(pypsa2smspp, "TransformationConfig") | ||
|
|
||
|
|
||
| def test_pypsa2smspp_basic_functionality(): | ||
| """Test basic pypsa2smspp functionality with a simple network.""" | ||
| import pypsa | ||
| import pypsa2smspp | ||
|
|
||
| # Create a simple PyPSA network | ||
| n = pypsa.Network() | ||
| n.add("Bus", "bus0") | ||
| n.add("Generator", "gen0", bus="bus0", p_nom=100, marginal_cost=50) | ||
| n.add("Load", "load0", bus="bus0", p_set=80) | ||
|
|
||
| # Verify the network was created | ||
| assert len(n.buses) == 1 | ||
| assert len(n.generators) == 1 | ||
| assert len(n.loads) == 1 | ||
|
|
||
| # Test that we can instantiate TransformationConfig | ||
| config = pypsa2smspp.TransformationConfig() | ||
| assert config is not None | ||
|
|
||
|
|
||
| def test_pypsa2smspp_config_loading(): | ||
| """Test that pypsa2smspp can load its default configuration.""" | ||
| import pypsa2smspp | ||
| import yaml | ||
| import os | ||
|
|
||
| # Find the config file | ||
| pypsa2smspp_path = pypsa2smspp.__file__ | ||
| config_path = os.path.join( | ||
| os.path.dirname(pypsa2smspp_path), "data", "config_default.yaml" | ||
| ) | ||
|
|
||
| assert os.path.exists(config_path), f"Config file not found at {config_path}" | ||
|
|
||
| # Load and verify config | ||
| with open(config_path) as f: | ||
| config = yaml.safe_load(f) | ||
|
|
||
| assert config is not None | ||
| assert isinstance(config, dict) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Limit to 3.13
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to Python 3.13 only in commit cb80a74.