Skip to content

Commit

Permalink
Test HierarchicalCodelist.__repr__()
Browse files Browse the repository at this point in the history
  • Loading branch information
khaeru committed Jan 10, 2024
1 parent 8353152 commit 60cc441
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sdmx/tests/model/test_v21.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import sdmx
import sdmx.message
from sdmx.model import v21 as model
from sdmx.model.v21 import (
AttributeDescriptor,
AttributeValue,
Expand Down Expand Up @@ -610,6 +611,10 @@ def msg(self, specimen):
with specimen("BIS/hierarchicalcodelist-0.xml") as f:
return sdmx.read_sdmx(f)

@pytest.fixture(scope="class")
def obj(self, msg) -> model.HierarchicalCodelist:
return msg.hierarchical_codelist["BIS:HCL_COUNTRY(1.0)"]

def test_hierarchy(self, msg: sdmx.message.StructureMessage) -> None:
for key, hcl in msg.hierarchical_codelist.items():
assert 1 == len(hcl.hierarchy)
Expand Down Expand Up @@ -641,3 +646,6 @@ def test_hierarchy(self, msg: sdmx.message.StructureMessage) -> None:
c3 = c2.child[0]
assert "6J" == c3.code
assert c3.code.parent.urn.endswith("Codelist=BIS:CL_BIS_IF_REF_AREA(1.0)")

def test_repr(self, obj: model.HierarchicalCodelist):
assert "<HierarchicalCodelist HCL_COUNTRY: 1 hierarchies>" == repr(obj)

0 comments on commit 60cc441

Please sign in to comment.