Skip to content

Commit f42ad5c

Browse files
committed
Add tests of IEA_EWEB
1 parent 1cd5ed0 commit f42ad5c

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

message_ix_models/tests/tools/iea/test_web.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
import pandas as pd
55
import pytest
6+
from genno import Computer
67

8+
from message_ix_models.tools.exo_data import prepare_computer
79
from message_ix_models.tools.iea.web import (
810
DIMS,
911
FILES,
@@ -14,6 +16,53 @@
1416
from message_ix_models.util import package_data_path
1517

1618

19+
class TestIEA_EWEB:
20+
@pytest.mark.parametrize("source", ("IEA_EWEB",))
21+
@pytest.mark.parametrize(
22+
"source_kw",
23+
(
24+
dict(
25+
provider="OECD", edition="2021", product=["CHARCOAL"], flow=["RESIDENT"]
26+
),
27+
# All flows related to transport
28+
dict(
29+
provider="OECD",
30+
edition="2022",
31+
flow=[
32+
"DOMESAIR",
33+
"DOMESNAV",
34+
"PIPELINE",
35+
"RAIL",
36+
"ROAD",
37+
"TOTTRANS",
38+
"TRNONSPE",
39+
"WORLDAV",
40+
"WORLDMAR",
41+
],
42+
),
43+
),
44+
)
45+
def test_prepare_computer(self, test_context, source, source_kw):
46+
# FIXME The following should be redundant, but appears mutable on GHA linux and
47+
# Windows runners.
48+
test_context.model.regions = "R14"
49+
50+
c = Computer()
51+
52+
keys = prepare_computer(test_context, c, source, source_kw)
53+
54+
# Preparation of data runs successfully
55+
result = c.get(keys[0])
56+
# print(result.to_string())
57+
58+
# Data has the expected dimensions
59+
assert {"n", "y", "product", "flow"} == set(result.dims)
60+
61+
# Data is complete
62+
assert 14 == len(result.coords["n"])
63+
assert {1980, 2020} < set(result.coords["y"].data)
64+
65+
1766
@pytest.mark.parametrize("provider, edition", FILES.keys())
1867
def test_load_data(test_context, tmp_path, provider, edition):
1968
# # Store in the temporary directory for this test

0 commit comments

Comments
 (0)