28 lines
874 B
Python
28 lines
874 B
Python
"""pfs.anchors — metadata for chunks: codes, families, and element slugs."""
|
|
|
|
from pfs.anchors import anchor_metadata
|
|
from pfs.families import Family
|
|
|
|
|
|
def test_codes_families_elements():
|
|
md = anchor_metadata(
|
|
"Use 99439 in conjunction with 99490; consent; per calendar month"
|
|
)
|
|
assert md["codes"] == "99439 99490"
|
|
assert md["families"] == "CCM"
|
|
assert (
|
|
"activity=consent" in md["elements"].split()
|
|
and "period=calendar-month" in md["elements"].split()
|
|
)
|
|
assert "relation=addon-of" in md["elements"].split() # detail dropped
|
|
|
|
|
|
def test_empty_and_unknown():
|
|
assert anchor_metadata("nothing here") == {
|
|
"codes": "",
|
|
"families": "",
|
|
"elements": "",
|
|
}
|
|
fams = {"X": Family("X", "X fam", ("12345",), ("x fam",))}
|
|
assert anchor_metadata("code 12345", families=fams)["families"] == "X"
|