summaryrefslogtreecommitdiff
path: root/test/test_diff.py
diff options
context:
space:
mode:
authorEdmond Chuc <e.chuc@uq.edu.au>2021-07-14 13:46:02 +1000
committerEdmond Chuc <e.chuc@uq.edu.au>2021-07-14 13:46:02 +1000
commitde260a5a3f33abe3133095dbf96cc19a50c90dee (patch)
tree229ec5c3ec70cf29a3ef0509b955c46ff3816dfa /test/test_diff.py
parent8bbbcc7daeb9adcb2880e3621aa5ae5122eb4208 (diff)
parentb81eaa4f23ae1978f5ca5e0236db7a95472cc0db (diff)
downloadrdflib-de260a5a3f33abe3133095dbf96cc19a50c90dee.tar.gz
Merge branch 'master' into hsolbrig/master
# Conflicts: # rdflib/namespace/__init__.py # rdflib/plugins/sparql/operators.py # test/test_namespace.py
Diffstat (limited to 'test/test_diff.py')
-rw-r--r--test/test_diff.py51
1 files changed, 50 insertions, 1 deletions
diff --git a/test/test_diff.py b/test/test_diff.py
index 0fb8d265..e33bd452 100644
--- a/test/test_diff.py
+++ b/test/test_diff.py
@@ -1,10 +1,19 @@
+from typing import Set, Tuple
import unittest
+from unittest.case import expectedFailure
import rdflib
from rdflib.compare import graph_diff
+from rdflib.namespace import RDF, FOAF
+from rdflib import Graph
+from rdflib.term import Node, BNode, Literal
+from .testutils import GraphHelper
-"""Test for graph_diff - much more extensive testing
+"""Test for graph_diff - much more extensive testing
would certainly be possible"""
+_TripleT = Tuple[Node, Node, Node]
+_TripleSetT = Set[_TripleT]
+
class TestDiff(unittest.TestCase):
"""Unicode literals for graph_diff test
@@ -25,6 +34,46 @@ class TestDiff(unittest.TestCase):
diff = graph_diff(g, g)
+ @expectedFailure
+ def test_subsets(self) -> None:
+ """
+ This test verifies that `graph_diff` returns the correct values
+ for two graphs, `g0` and `g1` where the triples in `g0` is a
+ subset of the triples in `g1`.
+
+ The expectation is that graph_diff reports that there are no
+ triples only in `g0`, and that there are triples that occur in both
+ `g0` and `g1`, and that there are triples only in `g1`.
+ """
+ g0_ts: _TripleSetT = set()
+ bnode = BNode()
+ g0_ts.update(
+ {
+ (bnode, FOAF.name, Literal("Golan Trevize")),
+ (bnode, RDF.type, FOAF.Person),
+ }
+ )
+ g0 = Graph()
+ g0 += g0_ts
+
+ g1_ts: _TripleSetT = set()
+ bnode = BNode()
+ g1_ts.update(
+ {
+ *g0_ts,
+ (bnode, FOAF.name, Literal("Janov Pelorat")),
+ (bnode, RDF.type, FOAF.Person),
+ }
+ )
+ g1 = Graph()
+ g1 += g1_ts
+
+ result = graph_diff(g0, g1)
+ in_both, in_first, in_second = GraphHelper.triple_sets(result)
+ self.assertFalse(in_first)
+ self.assertTrue(in_second)
+ self.assertTrue(in_both)
+
if __name__ == "__main__":
unittest.main()