@@ -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