Skip to content

Commit

Permalink
Remove pytest marker and rename test function, fixes #801
Browse files Browse the repository at this point in the history
  • Loading branch information
nesnoj committed Jun 10, 2022
1 parent 81d3e26 commit 21a6f90
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
read_rs7_data,
)
from egon.data.datasets.emobility.motorized_individual_travel.tests import (
test_ev_numbers,
validate_electric_vehicles_numbers,
)
from egon.data.datasets.mv_grid_districts import MvGridDistricts
from egon.data.datasets.scenario_parameters import get_sector_parameters
Expand Down Expand Up @@ -451,7 +451,7 @@ def allocate_evs_numbers():
)
# Check EV results if not in testmode
if TESTMODE_OFF:
test_ev_numbers(
validate_electric_vehicles_numbers(
"EV count in registration districts", ev_data, ev_target
)
# Add scenario columns and write to DB
Expand All @@ -476,7 +476,7 @@ def allocate_evs_numbers():
ev_data_muns = calc_evs_per_municipality(ev_data, rs7_data)
# Check EV results if not in testmode
if TESTMODE_OFF:
test_ev_numbers(
validate_electric_vehicles_numbers(
"EV count in municipalities", ev_data_muns, ev_target
)
# Add scenario columns and write to DB
Expand All @@ -500,7 +500,7 @@ def allocate_evs_numbers():
ev_data_mvgds = calc_evs_per_grid_district(ev_data_muns)
# Check EV results if not in testmode
if TESTMODE_OFF:
test_ev_numbers(
validate_electric_vehicles_numbers(
"EV count in grid districts", ev_data_mvgds, ev_target
)
# Add scenario columns and write to DB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,17 @@
"""

from numpy.testing import assert_allclose
import pytest

from egon.data.datasets.emobility.motorized_individual_travel.helpers import (
CONFIG_EV,
)


@pytest.mark.skip(
reason="Can only be tested with eGon database."
)
def test_ev_numbers(dataset_name, ev_data, ev_target):
"""Validate cumulative numbers of electric vehicles' distribution
def validate_electric_vehicles_numbers(dataset_name, ev_data, ev_target):
"""Validate cumulative numbers of electric vehicles' distribution.
Tests
* Check if all cells are not nan
* Check if all cells are not NaN
* Check if total number matches produced results (tolerance: 0.01 %)
Parameters
Expand All @@ -29,7 +25,7 @@ def test_ev_numbers(dataset_name, ev_data, ev_target):
ev_target : int
Desired number of EVs
"""
assert ev_data.isna().any().any() is False
assert not ev_data.isna().any().any()

assert_allclose(
ev_data[[_ for _ in CONFIG_EV.keys()]].sum().sum(),
Expand Down

0 comments on commit 21a6f90

Please sign in to comment.