Skip to content

Commit 25805c0

Browse files
committed
[test_rdf_reader.py] Add Tests for Mandatory Section and Property Attributes
1 parent 6ef5240 commit 25805c0

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/test_rdf_reader.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,31 @@ def test_property(self):
105105
self.assertEqual(prop.uncertainty, "0.8")
106106
self.assertEqual(prop.value_origin, "force")
107107
self.assertEqual(prop.reference, "Experiment 1")
108+
109+
def test_mandatory_attrs_section(self):
110+
"""
111+
Test if ParserError is thrown if mandatory attributes are missing for section.
112+
"""
113+
w = RDFWriter([self.doc])
114+
w.convert_to_rdf()
115+
for rdf_sec in w.graph.subjects(predicate=odmlns.hasName, object=Literal("sec1")):
116+
w.graph.remove((rdf_sec, odmlns.hasName, Literal("sec1")))
117+
118+
new_graph = w.graph.serialize(format="turtle").decode("utf-8")
119+
120+
with self.assertRaises(ParserException):
121+
RDFReader().from_string(new_graph, "turtle")
122+
123+
def test_mandatory_attrs_property(self):
124+
"""
125+
Test if ParserError is thrown if mandatory attributes are missing for section.
126+
"""
127+
w = RDFWriter([self.doc])
128+
w.convert_to_rdf()
129+
for rdf_sec in w.graph.subjects(predicate=odmlns.hasName, object=Literal("prop1")):
130+
w.graph.remove((rdf_sec, odmlns.hasName, Literal("prop1")))
131+
132+
new_graph = w.graph.serialize(format="turtle").decode("utf-8")
133+
134+
with self.assertRaises(ParserException):
135+
RDFReader().from_string(new_graph, "turtle")

0 commit comments

Comments
 (0)