Skip to content

Commit

Permalink
Add tests of .tools.check()
Browse files Browse the repository at this point in the history
  • Loading branch information
khaeru committed Aug 27, 2021
1 parent 3722296 commit 71ea5b7
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions message_ix/tests/tools/test_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import pytest

from message_ix import Scenario, make_df
from message_ix.testing import make_dantzig, make_westeros
from message_ix.tools import check


def test_check_dantzig(test_mp):
scen = make_dantzig(test_mp)

# Checks all True
results = check(scen)
assert results[0]


def test_check_westeros(test_mp):
scen = make_westeros(test_mp)

# Minimal config to make Westeros reportable
config = {"units": {"replace": {"-": ""}}}

# Checks all pass
results = check(scen, config=config)
assert results[0]

# Delete one value
to_delete = make_df(
"input",
node_loc="Westeros",
technology="bulb",
year_vtg=690,
year_act=710,
mode="standard",
node_origin="Westeros",
commodity="electricity",
level="final",
time="year",
time_origin="year",
).dropna(axis=1)
with scen.transact():
scen.remove_par("input", to_delete)

# Checks fail
results = check(scen, config=config)
assert not results[0]

0 comments on commit 71ea5b7

Please sign in to comment.