aboutsummaryrefslogtreecommitdiffstats
path: root/test/extractor
diff options
context:
space:
mode:
Diffstat (limited to 'test/extractor')
-rw-r--r--test/extractor/generic/test_constant.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/extractor/generic/test_constant.py b/test/extractor/generic/test_constant.py
index 7fdb8ac..aa33fb4 100644
--- a/test/extractor/generic/test_constant.py
+++ b/test/extractor/generic/test_constant.py
@@ -78,6 +78,43 @@ class TestConstant(unittest.TestCase):
#self.assertRaises(ValueError, Constant, schema, [
# (ns.bse.author, Foo())])
+ def test_eq(self):
+ schema_a = '''
+ bse:author rdfs:subClassOf bsfs:Predicate ;
+ rdfs:domain bsfs:Entity ;
+ rdfs:range xsd:string ;
+ owl:maxCardinality "1"^^xsd:number .
+ '''
+ schema_b = '''
+ bse:comment rdfs:subClassOf bsfs:Predicate ;
+ rdfs:domain bsfs:Entity ;
+ rdfs:range xsd:string ;
+ owl:maxCardinality "INF"^^xsd:number .
+ '''
+ tuples_a = [(ns.bse.author, 'Me, myself, and I')]
+ tuples_b = [(ns.bse.comment, 'the quick brown fox jumps over the lazy dog.') ]
+ # distinct instances, same data
+ self.assertEqual(
+ Constant(schema_a, tuples_a),
+ Constant(schema_a, tuples_a))
+ self.assertEqual(
+ hash(Constant(schema_a, tuples_a)),
+ hash(Constant(schema_a, tuples_a)))
+ # different data
+ self.assertNotEqual(
+ Constant(schema_a, tuples_a),
+ Constant(schema_b, tuples_b))
+ self.assertNotEqual(
+ hash(Constant(schema_a, tuples_a)),
+ hash(Constant(schema_b, tuples_b)))
+ # different objects
+ class Foo(): pass
+ self.assertNotEqual(Constant(schema_a, tuples_a), Foo())
+ self.assertNotEqual(hash(Constant(schema_a, tuples_a)), hash(Foo()))
+ self.assertNotEqual(Constant(schema_a, tuples_a), 123)
+ self.assertNotEqual(hash(Constant(schema_a, tuples_a)), hash(123))
+ self.assertNotEqual(Constant(schema_a, tuples_a), None)
+ self.assertNotEqual(hash(Constant(schema_a, tuples_a)), hash(None))
## main ##