Skip to content

Commit

Permalink
Add tests of .v21.MetadataSet & parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
khaeru committed Dec 30, 2023
1 parent f2abcc4 commit e916ba8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions sdmx/tests/model/test_v21.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,27 @@ def test_init(self):
assert ds0.action == ds1.action


class TestMetadataSet:
@pytest.fixture(scope="class")
def msg(self, specimen) -> sdmx.message.MetadataMessage:
with specimen("esms_generic.xml") as f:
return sdmx.read_sdmx(f)

def test_report_hierarchy(self, msg: sdmx.message.MetadataMessage) -> None:
# Access message → metadata set → report
r = msg.data[0].report[0]

# Number of top-level ReportedAttribute
assert 3 == len(r.metadata)
# Number of ReportedAttribute in tree branches
assert 4 == len(r.metadata[0])
assert 0 == len(r.metadata[0][0])
assert 4 == len(r.metadata[0][2])
assert 0 == len(r.metadata[0][2][0])
assert 3 == len(r.metadata[1])
assert 1 == len(r.metadata[2])


class TestHierarchicalCodelist:
@pytest.fixture(scope="class")
def msg(self, specimen):
Expand Down

0 comments on commit e916ba8

Please sign in to comment.