[tracker/IorR-null-support: 7/12] tests: Add functional test for insert or replace null support



commit 7a70d4b4c74e74ed650832d6dedb27ca29d7e315
Author: Philip Van Hoof <philip codeminded be>
Date:   Thu Aug 11 13:27:48 2011 +0200

    tests: Add functional test for insert or replace null support

 tests/functional-tests/01-insertion.py |   50 ++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)
---
diff --git a/tests/functional-tests/01-insertion.py b/tests/functional-tests/01-insertion.py
index 256f6e7..5f01308 100755
--- a/tests/functional-tests/01-insertion.py
+++ b/tests/functional-tests/01-insertion.py
@@ -562,6 +562,56 @@ class TrackerStoreInsertionTests (CommonTrackerStoreTest):
                 """ % (url))
 
 
+	def test_insert_replace_null(self):
+                """
+                Insert or replace, with null
+                """
+
+                self.tracker.update("""INSERT { <test://instance-null> a nie:DataObject, nie:InformationElement }""")
+                self.tracker.update("""INSERT { <test://instance-ds1> a nie:DataSource  }""")
+                self.tracker.update("""INSERT { <test://instance-ds2> a nie:DataSource  }""")
+                self.tracker.update("""INSERT { <test://instance-ds3> a nie:DataSource  }""")
+                self.tracker.update("""INSERT { <subject> nie:dataSource <ds1>, <ds2>, <ds3> }""")
+
+                # null upfront, reset of list, rewrite of new list
+                self.tracker.update("""INSERT OR REPLACE { <test://instance-null> nie:dataSource null, <test://instance-ds1>, <test://instance-ds2> }""")
+                result = self.tracker.query ("""SELECT ?ds WHERE { <test://instance-null> nie:dataSource ?ds }""")			
+                self.assertEquals (len (result), 2)
+                self.assertEquals (len (result[0]), 1)
+                self.assertEquals (len (result[1]), 1)
+                self.assertEquals (result[0][0], "test://instance-ds1")
+                self.assertEquals (result[1][0], "test://instance-ds2")
+
+                # null upfront, reset of list, rewrite of new list, second test
+                self.tracker.update("""INSERT OR REPLACE { <test://instance-null> nie:dataSource null, <test://instance-ds1>, <test://instance-ds2>, <test://instance-ds3> }""")
+                result = self.tracker.query ("""SELECT ?ds WHERE { <test://instance-null> nie:dataSource ?ds }""")			
+                self.assertEquals (len (result), 3)
+                self.assertEquals (len (result[0]), 1)
+                self.assertEquals (len (result[1]), 1)
+                self.assertEquals (len (result[2]), 1)
+                self.assertEquals (result[0][0], "test://instance-ds1")
+                self.assertEquals (result[1][0], "test://instance-ds2")
+                self.assertEquals (result[2][0], "test://instance-ds3")
+
+                # null in the middle, rewrite of new list
+                self.tracker.update("""INSERT OR REPLACE { <test://instance-null> nie:dataSource <test://instance-ds1>, null, <test://instance-ds2>, <test://instance-ds3> }""")
+                result = self.tracker.query ("""SELECT ?ds WHERE { <test://instance-null> nie:dataSource ?ds }""")			
+                self.assertEquals (len (result), 2)
+                self.assertEquals (len (result[0]), 1)
+                self.assertEquals (len (result[1]), 1)
+                self.assertEquals (result[0][0], "test://instance-ds2")
+                self.assertEquals (result[1][0], "test://instance-ds3")
+				
+                # null at the end
+                self.tracker.update("""INSERT OR REPLACE { <test://instance-null> nie:dataSource <test://instance-ds1>, <test://instance-ds2>, <test://instance-ds3>, null }""")
+                result = self.tracker.query ("""SELECT ?ds WHERE { <test://instance-null> nie:dataSource ?ds }""")			
+                self.assertEquals (len (result), 0)
+	
+                self.tracker.update ("""DELETE { <test://instance-null> a rdfs:Resource. }""")				
+                self.tracker.update ("""DELETE { <test://instance-ds1> a rdfs:Resource. }""")				
+                self.tracker.update ("""DELETE { <test://instance-ds2> a rdfs:Resource. }""")				
+                self.tracker.update ("""DELETE { <test://instance-ds3> a rdfs:Resource. }""")				
+
 class TrackerStoreDeleteTests (CommonTrackerStoreTest):
         """
         Use DELETE in Sparql and check the information is actually removed



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]