Skip to content

Commit 40476d8

Browse files
committed
Add .tests.report.legacy.test_iamc_report_hackathon
Copied from iiasa/message_data branch `dev`.
1 parent 92dbc84 commit 40476d8

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import pytest
2+
from message_ix_models import testing
3+
from message_ix_models.util import MESSAGE_DATA_PATH
4+
5+
from message_data.tools.post_processing import iamc_report_hackathon
6+
7+
8+
@pytest.mark.parametrize("set_out_dir", [False, True])
9+
def test_report(caplog, request, test_context, set_out_dir):
10+
"""Invoke :func:`.iamc_report_hackathon.report` directly."""
11+
# Mandatory arguments to report(): a scenario and its platform
12+
scenario = testing.bare_res(request, test_context, solved=False)
13+
14+
# Set dry_run = True to not actually perform any calculations or modifications
15+
test_context.dry_run = True
16+
17+
if set_out_dir:
18+
expected = test_context.get_local_path("report", "foo")
19+
args = dict(out_dir=expected)
20+
else:
21+
# Do not provide out_dir/no arguments
22+
args = dict()
23+
expected = MESSAGE_DATA_PATH.joinpath("reporting_output")
24+
25+
# Call succeeds
26+
iamc_report_hackathon.report(
27+
scenario.platform, scenario, context=test_context, **args
28+
)
29+
30+
# Dry-run message is logged
31+
assert "DRY RUN" in caplog.messages[-1]
32+
# Output directory is set
33+
assert caplog.messages[-1].endswith(str(expected))

0 commit comments

Comments
 (0)