示例#1
0
    def test_difference(self):
        larger_graph = get_empty_graph()
        larger_graph.add((URIRef(":Icaro"), RDF.type, URIRef(":Mortal")))
        larger_graph.add((URIRef(":Mortal"), RDF.type, OWL.Class))
        larger_graph.add((URIRef(":Human"), RDF.type, OWL.Class))

        subset_graph = get_empty_graph()
        subset_graph.add((URIRef(":Icaro"), RDF.type, URIRef(":Mortal")))
        self.assertTrue(is_empty_graph(difference(subset_graph, larger_graph)))
示例#2
0
 def _infer(self):
     """
         Method that constructs a ``diderot.inference.Inference`` object
         and trigger the inference.
     """
     inference = Inference()
     inference.add_facts(self.facts)
     inferred_facts = inference.get_inferred_facts()
     self.not_inferred_facts = difference(self.expected_facts, inferred_facts)
     if not self.not_inferred_facts:
         self.assertion_value = True
     else:
         self.assertion_value = False
         self._build_assertion_error_message()
示例#3
0
    def test_difference_not_empty(self):
        larger_graph = get_empty_graph()
        larger_graph.add((URIRef(":Icaro"), RDF.type, URIRef(":Mortal")))
        larger_graph.add((URIRef(":Mortal"), RDF.type, OWL.Class))
        larger_graph.add((URIRef(":Human"), RDF.type, OWL.Class))

        subset_graph = get_empty_graph()
        subset_graph.add((URIRef(":Icaro"), RDF.type, URIRef(":Mortal")))
        subset_graph.add((URIRef(":Icaro"), RDF.type, URIRef(":Student")))  # Not in larger_graph

        difference_expected_graph = get_empty_graph()
        difference_expected_graph.add((URIRef(":Icaro"), RDF.type, URIRef(":Student")))  # Not in larger_graph

        difference_expected_graph_set = set(difference_expected_graph)

        difference_result_graph_set = difference(subset_graph, larger_graph)

        self.assertEqual(len(difference_result_graph_set), 1)
        self.assertEqual(difference_expected_graph_set, difference_result_graph_set)