def test_all_classes_mode(self): shaper = Shaper( graph_file_input=G1, namespaces_dict=default_namespaces(), all_classes_mode=True, input_format=TURTLE, disable_comments=True) str_result = shaper.shex_graph(string_output=True, output_format=SHACL_TURTLE) self.assertTrue(graph_comparison_file_vs_str(file_path=_BASE_DIR + "g1_all_classes.ttl", str_target=str_result))
def test_no_annotation(self): shaper = Shaper(all_classes_mode=True, graph_file_input=_BASE_DIR + "wiki_example.ttl", instantiation_property="http://www.wikidata.org/prop/direct/P31", input_format="turtle", disable_comments=True, ) str_result = shaper.shex_graph(string_output=True, output_format=SHACL_TURTLE) self.assertTrue(graph_comparison_file_vs_str(file_path=_BASE_DIR + "wiki_example_noanot_shacl.ttl", str_target=str_result))
def test_some_classes_with_target_classes(self): shaper = Shaper( graph_file_input=G1, namespaces_dict=default_namespaces(), all_classes_mode=False, target_classes=["http://xmlns.com/foaf/0.1/Person"], input_format=TURTLE, disable_comments=True) str_result = shaper.shex_graph(string_output=True, output_format=SHACL_TURTLE) self.assertTrue(graph_comparison_file_vs_str(file_path=_BASE_DIR + "g1_person.ttl", str_target=str_result))
def test_different_literals(self): shaper = Shaper( all_classes_mode=True, graph_file_input=_BASE_DIR + "different_literals.ttl", input_format="turtle", disable_comments=True, ) str_result = shaper.shex_graph(string_output=True, output_format=SHACL_TURTLE) self.assertTrue( graph_comparison_file_vs_str(file_path=_BASE_DIR + "different_literals_shacl.ttl", str_target=str_result))
def test_annotation(self): shaper = Shaper(all_classes_mode=True, graph_file_input=_BASE_DIR + "wiki_example.ttl", instantiation_property="http://www.wikidata.org/prop/direct/P31", input_format="turtle", disable_comments=True, wikidata_annotation=True ) str_result = shaper.shex_graph(string_output=True, output_format=SHACL_TURTLE) print(str(str_result)) self.assertTrue(graph_comparison_file_vs_str(file_path=_BASE_DIR + "wiki_example_noanot_shacl.ttl", str_target=str_result)) self.assertTrue(text_contains_lines(text=str_result, list_lines=[ "# P31 --> instance of", "# Q11689315 --> hipopotams", "# Q215627 --> person", "# Q5 --> human" ]))