[tracker/sparql-update] libtracker-data: Functional test for REPLACE support



commit 3c14ec08b940799929aa08744d30fc19f09276cf
Author: Philip Van Hoof <philip codeminded be>
Date:   Fri Mar 11 10:30:07 2011 +0100

    libtracker-data: Functional test for REPLACE support

 tests/functional-tests/01-insertion.py |   64 ++++++++++++++++++++++++++++++++
 1 files changed, 64 insertions(+), 0 deletions(-)
---
diff --git a/tests/functional-tests/01-insertion.py b/tests/functional-tests/01-insertion.py
index 2f5e869..f85485f 100755
--- a/tests/functional-tests/01-insertion.py
+++ b/tests/functional-tests/01-insertion.py
@@ -232,6 +232,70 @@ class TrackerStoreInsertionTests (CommonTrackerStoreTest):
                 DELETE { <test://instance-1> a rdfs:Resource. }
                 """)
 
+
+	def test_insert_05(self):
+                """
+                Insert or replace, single valued properties multiple times.
+                """
+                for i in range (0, 3):
+                        # Insert the same single valued properties of music file.
+                        self.tracker.update("""
+                        INSERT OR REPLACE {
+                           <test://instance-1> a nmm:MusicPiece, nfo:FileDataObject;
+                           nie:usageCounter '%d';
+                           nie:contentAccessed '2000-01-01T00:4%d:47Z' .
+                        }""" % (i, i))
+
+                        # Query for the property values and verify whether the last change is applied.
+                        result = self.tracker.query ("""
+                          SELECT ?playcount ?date WHERE {
+                             <test://instance-1> a nmm:MusicPiece ;
+                                 nie:usageCounter ?playcount ;
+                                 nie:contentAccessed ?date.
+                          }""")
+
+                        self.assertEquals (len (result), 1)
+                        self.assertEquals (len (result[0]), 2)
+                        self.assertEquals (int (result[0][0]), i)
+                        self.assertEquals (result[0][1], "2000-01-01T00:4%d:47Z" % (i))
+
+                self.tracker.update ("""
+                DELETE { <test://instance-1> a rdfs:Resource. }
+                """)
+
+                for i in range (0, 3):
+                        # Insert the same single valued properties of music file.
+                        self.tracker.update("""
+                        INSERT OR REPLACE {
+                           <test://instance-2> a nie:InformationElement;
+                           nie:title '%d';
+                           nie:keyword '%d'
+                        }""" % (i, i))
+
+                        # Query for the property values and verify whether the last change is applied.
+                        result = self.tracker.query ("""
+                          SELECT ?t ?k WHERE {
+                             <test://instance-2> nie:title ?t ;
+                                 nie:keyword ?k 
+                          }""")
+
+                self.assertEquals (len (result), 3)
+                self.assertEquals (len (result[0]), 2)
+                self.assertEquals (result[0][0], "%d" % i)
+                self.assertEquals (result[0][1], "0")
+
+                self.assertEquals (result[1][0], "%d" % i)
+                self.assertEquals (result[1][1], "1")
+
+                self.assertEquals (result[2][0], "%d" % i)
+                self.assertEquals (result[2][1], "2")
+
+                self.tracker.update ("""
+                DELETE { <test://instance-2> a rdfs:Resource. }
+                """)
+
+
+
         def __insert_valid_date_test (self, datestring, year, month, day, hours, minutes, seconds, timezone):
                 """
                 Insert a property with datestring value, retrieve its components and validate against



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