[tracker/miner-web: 47/76] Add functional test for tracker-miner-fs insert/update behavior.
- From: Adrien Bustany <abustany src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/miner-web: 47/76] Add functional test for tracker-miner-fs insert/update behavior.
- Date: Tue, 2 Mar 2010 20:19:46 +0000 (UTC)
commit 9efb7b9d7684fe5659ebb6a43779c70550d114aa
Author: Carlos Garnacho <carlos lanedo com>
Date: Thu Feb 25 16:41:10 2010 +0100
Add functional test for tracker-miner-fs insert/update behavior.
tests/functional-tests/08-unique-insertions.py | 85 ++++++++++++++++++++++++
tests/functional-tests/Makefile.am | 1 +
2 files changed, 86 insertions(+), 0 deletions(-)
---
diff --git a/tests/functional-tests/08-unique-insertions.py b/tests/functional-tests/08-unique-insertions.py
new file mode 100644
index 0000000..e887f83
--- /dev/null
+++ b/tests/functional-tests/08-unique-insertions.py
@@ -0,0 +1,85 @@
+#!/usr/bin/env python2.5
+
+# Copyright (C) 2008, Nokia (urho konttori nokia com)
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+#
+
+
+import dbus
+import unittest
+import random
+
+TRACKER = 'org.freedesktop.Tracker1'
+TRACKER_OBJ = '/org/freedesktop/Tracker1/Resources'
+RESOURCES_IFACE = "org.freedesktop.Tracker1.Resources"
+
+class TestFTSFunctions (unittest.TestCase):
+
+ def setUp (self):
+ bus = dbus.SessionBus ()
+ tracker = bus.get_object (TRACKER, TRACKER_OBJ)
+ self.resources = dbus.Interface (tracker,
+ dbus_interface=RESOURCES_IFACE);
+
+ def test_unique_insertion (self):
+ """
+ We actually can't test tracker-miner-fs, so we mimick its behavior in this test
+ 1. Insert one resource
+ 2. Update it like tracker-miner-fs does
+ 3. Check there isn't any duplicate
+ 4. Clean up
+ """
+
+ resource = 'graph://test/resource/1'
+
+ insert_sparql = """
+ DROP GRAPH <graph://test/resource/1>
+ INSERT INTO <graph://test/resource/1> {
+ _:resource a nie:DataObject ;
+ nie:url "%s" .
+ }
+ """ % resource
+
+ select_sparql = """
+ SELECT ?u { ?u nie:url "%s" }
+ """ % resource
+
+ delete_sparql = """
+ DROP GRAPH <graph://test/resource/1>
+ """
+
+ ''' First insertion '''
+ self.resources.SparqlUpdate (insert_sparql)
+
+ results = self.resources.SparqlQuery (select_sparql)
+ self.assertEquals (len(results), 1)
+
+ ''' Second insertion / update '''
+ self.resources.SparqlUpdate (insert_sparql)
+
+ results = self.resources.SparqlQuery (select_sparql)
+ self.assertEquals (len(results), 1)
+
+ ''' Clean up '''
+ self.resources.SparqlUpdate (delete_sparql)
+
+ results = self.resources.SparqlQuery (select_sparql)
+ self.assertEquals (len(results), 0)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/functional-tests/Makefile.am b/tests/functional-tests/Makefile.am
index 974c159..713719d 100644
--- a/tests/functional-tests/Makefile.am
+++ b/tests/functional-tests/Makefile.am
@@ -17,6 +17,7 @@ config_DATA = \
05-coalesce.py \
06-distance.py \
07-graph.py \
+ 08-unique-insertions.py \
virtual-files-tc.py
EXTRA_DIST = $(config_DATA)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]