def test_new(content): ann = Annotation(**content) assert ann.type == content["type"] assert ann.value == content["value"] assert ann.source == content["source"] assert ann.source_ID == content["source_ID"] assert ann.span == content["span"] assert ann.attributes == content["attributes"] assert ann.isEntity == content["isEntity"] assert ann.ID == content["ID"] assert ann.ngram == content["ngram"]
def test_to_json(content): ann = Annotation(**content) ann_json = ann.to_json() ann_json == json.dumps(content)
def test_to_dict(content): ann = Annotation(**content) ann_dict = ann.to_dict() assert ann_dict == content
def test_init_missing_source_ID(self, content): with pytest.raises(TypeError): ann = Annotation(type=content["type"], value=content["value"], source=content["source"])
def test_init_empty(self): with pytest.raises(TypeError): ann = Annotation()