Commit 4edb8fde authored by Marius Kriegerowski's avatar Marius Kriegerowski
Browse files

fix tags

parent 5f4a1124
......@@ -47,9 +47,10 @@ class GEMTag:
def from_string(cls, tag_as_string: str) -> GEMTag:
"""Instantiate `GEMClassification`s from GEM occupancy string."""
matched =, tag_as_string, re.IGNORECASE)
assert matched is not None, f"could not convert '{tag_as_string}' to GEMTag"
group = str("group"))
assert len(group) > 0, f"could not extract a GEM group from {tag_as_string}"
assert group, f"could not extract `group` from {tag_as_string}"
sub_group ="sub_group")
sub_group = int(sub_group) if sub_group != "" else None
......@@ -56,11 +56,9 @@ def test_overriding_occupancy(overriding_occupancies):
assert occupancy == GEMTag.from_string("COM10")
def test_overriding_occupancy_unknown(overriding_occupancies):
"""Rule #1"""
demo_tags = TagStatistics.from_strings(["unknown tag"])
occupancy = overriding_occupancies.apply(demo_tags)
assert occupancy is None
def test_overriding_occupancy_unknown():
with pytest.raises(AssertionError):
TagStatistics.from_strings(["unknown tag"])
def test_unique_tags():
......@@ -47,6 +47,11 @@ def test_gem_classification_parser():
assert GEMTag.from_string("UNDECIDABLE").sub_group is None
with pytest.raises(AssertionError):
# Tag must not contain whitespace
GEMTag.from_string("unknown tag")
with pytest.raises(AssertionError):
# Tag must start with character (group)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment