1+ import pandas as pd
2+ import pyam
13import pytest
4+ from message_ix import Reporter , Scenario
25from pytest import param
36
4- from message_ix_models .model .material .report .run_reporting import load_config , run
5- from message_ix_models .tests .test_tools import scenario # noqa: F401
7+ from message_ix_models import Context
8+ from message_ix_models .model .material .report .run_reporting import (
9+ load_config ,
10+ run ,
11+ run_ch4_reporting ,
12+ run_fe_methanol_nh3_reporting ,
13+ run_fe_reporting ,
14+ run_fs_reporting ,
15+ run_prod_reporting ,
16+ split_fe_other ,
17+ )
18+ from message_ix_models .testing import bare_res
19+
20+ MARK = pytest .mark .xfail (reason = "Fixture scenario does not have materials contents" )
21+
22+
23+ @pytest .fixture
24+ def reporter (scenario ) -> Reporter :
25+ return Reporter .from_scenario (scenario )
26+
27+
28+ @pytest .fixture
29+ def scenario (request : pytest .FixtureRequest , test_context : Context ) -> Scenario :
30+ test_context .model .regions = "R12"
31+ return bare_res (request , test_context , solved = False )
632
733
834@pytest .mark .parametrize (
@@ -28,7 +54,42 @@ def test_load_config(config_name, exp_len) -> None:
2854 # TODO Extend assertions
2955
3056
31- @pytest . mark . xfail ( reason = "Missing R12 scenario snapshot" , raises = ValueError )
32- def test_run (scenario ) -> None : # noqa: F811
57+ @MARK
58+ def test_run (scenario : Scenario ) -> None :
3359 run (scenario )
3460 # TODO Add assertions once test scenario is available
61+
62+
63+ @pytest .mark .parametrize (
64+ "func" ,
65+ [
66+ pytest .param (run_ch4_reporting , marks = MARK ),
67+ pytest .param (run_fe_reporting , marks = MARK ),
68+ run_fe_methanol_nh3_reporting ,
69+ pytest .param (run_fs_reporting , marks = MARK ),
70+ pytest .param (run_prod_reporting , marks = MARK ),
71+ ],
72+ )
73+ def test_other (reporter : Reporter , func ) -> None :
74+ """Placeholder tests for several functions with identical signatures."""
75+ result = func (reporter , "model name" , "scenario name" )
76+
77+ # TODO Add assertions
78+ del result
79+
80+
81+ @MARK
82+ def test_split_fe_other (reporter : Reporter ) -> None :
83+ split_fe_other (
84+ reporter ,
85+ # NB IamDataFrame() can't be initialized empty or with an empty df; this is the
86+ # shortest call that works
87+ pyam .IamDataFrame (
88+ pd .DataFrame (
89+ [["m" , "s" , "r" , "v" , "u" , 0 ]],
90+ columns = ["model" , "scenario" , "region" , "variable" , "unit" , "year" ],
91+ ).assign (value = 1.0 )
92+ ),
93+ "model name" ,
94+ "scenario name" ,
95+ )
0 commit comments