summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNicholas Car <nicholas.car@surroundaustralia.com>2020-05-25 08:58:18 +1000
committerNicholas Car <nicholas.car@surroundaustralia.com>2020-05-25 08:58:18 +1000
commit6b2af922b37b47651a5e6166b1dac50bee406383 (patch)
tree997daee2fbc534b8bce95f3c5fbce201fcb9f6be /test
parent91037207580838e41c07eb457bd65d7cc6d6ed85 (diff)
parentabcc91cf68fe2666f276fe7370a4f9eaa953a4e8 (diff)
downloadrdflib-6b2af922b37b47651a5e6166b1dac50bee406383.tar.gz
Merge branch 'master' of https://github.com/kushagr08/rdflib
Diffstat (limited to 'test')
-rw-r--r--test/test_container.py83
1 files changed, 83 insertions, 0 deletions
diff --git a/test/test_container.py b/test/test_container.py
new file mode 100644
index 00000000..4e061eb8
--- /dev/null
+++ b/test/test_container.py
@@ -0,0 +1,83 @@
+from rdflib.term import BNode
+from rdflib.term import Literal
+from random import randint
+from rdflib import Graph
+from rdflib.container import *
+import unittest
+
+
+class Test_Container(unittest.TestCase):
+
+ @classmethod
+ def setUpClass(self):
+ self.g = Graph()
+ self.c1 = Bag(self.g, BNode())
+ self.c2 = Bag(self.g, BNode(), [Literal('1'), Literal('2'), Literal('3'),
+ Literal('4')])
+ self.c3 = Alt(self.g, BNode(), [Literal('1'), Literal('2'), Literal('3'),
+ Literal('4')])
+ self.c4 = Seq(self.g, BNode(), [Literal('1'), Literal('2'), Literal('3'),
+ Literal('4')])
+
+ def testA(self):
+ self.assertEqual(len(self.c1) == 0, True)
+
+ def testB(self):
+ self.assertEqual(len(self.c2) == 4, True)
+
+ def testC(self):
+ self.c2.append(Literal('5'))
+ del self.c2[2]
+ self.assertEqual(len(self.c2) == 4, True)
+
+ def testD(self):
+ self.assertEqual(self.c2.index(Literal('5')) == 4, True)
+
+ def testE(self):
+ self.assertEqual(self.c2[2] == Literal('3'), True)
+
+ def testF(self):
+ self.c2[2] = Literal('9')
+ self.assertEqual(self.c2[2] == Literal('9'), True)
+
+ def testG(self):
+ self.c2.clear()
+ self.assertEqual(len(self.c2) == 0, True)
+
+ def testH(self):
+ self.c2.append_multiple([Literal('80'), Literal('90')])
+ self.assertEqual(self.c2[1] == Literal('80'), True)
+
+ def testI(self):
+ self.assertEqual(self.c2[2] == Literal('90'), True)
+
+ def testJ(self):
+ self.assertEqual(len(self.c2) == 2, True)
+
+ def testK(self):
+ self.assertEqual(self.c2.end() == 2, True)
+
+ def testL(self):
+ self.assertEqual(self.c3.anyone() in [Literal('1'), Literal('2'), Literal('3'),
+ Literal('4')], True)
+
+ def testM(self):
+ self.c4.add_at_position(3, Literal('60'))
+ self.assertEqual(len(self.c4) == 5, True)
+
+ def testN(self):
+ self.assertEqual(self.c4.index(Literal('60')) == 3, True)
+
+ def testO(self):
+ self.assertEqual(self.c4.index(Literal('3')) == 4, True)
+
+ def testP(self):
+ self.assertEqual(self.c4.index(Literal('4')) == 5, True)
+
+
+
+if __name__ == '__main__':
+
+ unittest.main()
+
+ \ No newline at end of file