Skip to content

Commit

Permalink
Add test that the data structure description can be written and read
Browse files Browse the repository at this point in the history
  • Loading branch information
khaeru committed Feb 22, 2021
1 parent ca14367 commit 258edb3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions item/tests/test_structure.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import sdmx

from item.sdmx import generate
from item.structure import column_name, make_template


Expand All @@ -19,3 +22,16 @@ def test_make_template(tmp_path):

assert 2493 + 1 == sum(1 for _ in open(tmp_path / "template.csv"))
assert 2493 + 2 == sum(1 for _ in open(tmp_path / "index.csv"))


def test_sdmx_roundtrip(tmp_path):
path = tmp_path / "structure.xml"

# Structure can be written
with open(path, "wb") as f:
f.write(sdmx.to_xml(generate(), pretty_print=True))

# Structure can be read
sm = sdmx.read_sdmx(path)

assert 3 == len(sm.constraint["PRICE_FUEL"].data_content_keys)

0 comments on commit 258edb3

Please sign in to comment.