Skip to content

Commit

Permalink
code: include requested comments to PR
Browse files Browse the repository at this point in the history
  • Loading branch information
finozzifa committed Nov 22, 2024
1 parent c36a4ea commit 3bb9b44
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,13 @@ jobs:
conda env update -n pypsa-eur -f ${{ env.env_file }}
echo "Run conda list" && conda list
- name: Run snakemake test workflows and unit tests
- name: Run snakemake test workflows
run: |
make test
- name: Run unit tests
run: |
make checks
make unit-test
- name: Upload artifacts
if: always()
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test:
snakemake --configfile config/test/config.scenarios.yaml --rerun-triggers=mtime -n
echo "All tests completed successfully."

checks: test
unit-test:
pytest test

# Cleans all output files from tests
Expand Down
2 changes: 1 addition & 1 deletion test/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# SPDX-FileCopyrightText: : 2017-2023 The PyPSA-Eur Authors
# SPDX-FileCopyrightText: : 2017-2024 The PyPSA-Eur Authors
#
# SPDX-License-Identifier: MIT
8 changes: 3 additions & 5 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,23 @@
# coding: utf-8

import pathlib
import shutil

import pypsa
import pytest
import yaml


@pytest.fixture(scope="function")
def get_power_network_scigrid_de():
def scigrid_network():
return pypsa.examples.scigrid_de(from_master=True)


@pytest.fixture(scope="function")
def get_power_network_ac_dc_meshed():
def ac_dc_network():
return pypsa.examples.ac_dc_meshed(from_master=True)


@pytest.fixture(scope="function")
def get_config_dict():
def config():
path_config = pathlib.Path(pathlib.Path.cwd(), "config", "config.default.yaml")
with open(path_config, "r") as file:
config_dict = yaml.safe_load(file)
Expand Down
11 changes: 4 additions & 7 deletions test/test_build_powerplants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@
Tests the functionalities of scripts/build_powerplants.py.
"""

import pathlib
import sys

import numpy as np
import pandas as pd
import pathlib
import pytest
import sys

sys.path.append("./scripts")

from test.conftest import get_config_dict

from build_powerplants import (
add_custom_powerplants,
replace_natural_gas_fueltype,
Expand All @@ -32,11 +29,11 @@
"query_value,expected",
[(False, (131, 18)), (True, (137, 18))],
)
def test_add_custom_powerplants(get_config_dict, query_value, expected):
def test_add_custom_powerplants(config, query_value, expected):
"""
Verify what returned by add_custom_powerplants.
"""
config_dict = get_config_dict
config_dict = config
config_dict["electricity"]["custom_powerplants"] = query_value
custom_powerplants_path = pathlib.Path(
path_cwd, "test", "test_data", "custom_powerplants_DE.csv"
Expand Down

0 comments on commit 3bb9b44

Please sign in to comment.