[tracker] Functional test for coalesce
- From: Ivan Frade <ifrade src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker] Functional test for coalesce
- Date: Tue, 2 Feb 2010 17:10:28 +0000 (UTC)
commit a65fcc9ca6567f35fb5774ca24aa07ed960934ad
Author: Ivan Frade <ivan frade nokia com>
Date: Tue Feb 2 19:01:00 2010 +0200
Functional test for coalesce
tests/functional-tests/05-coalesce.py | 120 +++++++++++++++++++++++++++++++++
tests/functional-tests/tests.xml | 6 ++
2 files changed, 126 insertions(+), 0 deletions(-)
---
diff --git a/tests/functional-tests/05-coalesce.py b/tests/functional-tests/05-coalesce.py
new file mode 100644
index 0000000..a75fe3b
--- /dev/null
+++ b/tests/functional-tests/05-coalesce.py
@@ -0,0 +1,120 @@
+#!/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 TestCoalesce (unittest.TestCase):
+
+ def setUp (self):
+ bus = dbus.SessionBus ()
+ tracker = bus.get_object (TRACKER, TRACKER_OBJ)
+ self.resources = dbus.Interface (tracker,
+ dbus_interface=RESOURCES_IFACE);
+
+ self.resource_uri = "contact://test_group_concat"
+
+ #
+ # nco:nickname and nco:note are not set
+ #
+ insert = """
+ INSERT { <%s> a nco:IMContact;
+ nco:fullname \"full name\" ;
+ nco:nameFamily \"family name\" .
+ }
+ """ % (self.resource_uri)
+ self.resources.SparqlUpdate (insert)
+
+ def tearDown (self):
+ delete = """
+ DELETE { <%s> a rdfs:Resource. }
+ """ % (self.resource_uri)
+ self.resources.SparqlUpdate (delete)
+
+
+
+ def test_coalesce_first_fine (self):
+ """
+ setUp: Insert a contact with only some text properties set
+ 1. TEST: run a query with coalesce with the valid value in different positions
+ tearDown: Remove the test contact inserted
+ """
+
+ query = """
+ SELECT tracker:coalesce (?full, ?family, ?nickname, ?note, 'test_coalesce') WHERE {
+ ?c a nco:IMContact .
+ OPTIONAL { ?c nco:fullname ?full }
+ OPTIONAL { ?c nco:nameFamily ?family }
+ OPTIONAL { ?c nco:nickname ?nickname }
+ OPTIONAL { ?c nco:note ?note }
+ }
+ """
+ results = self.resources.SparqlQuery (query)
+ assert results[0][0] == "full name"
+
+
+ def test_coalesce_second_fine (self):
+ """
+ setUp: Insert a contact with only some text properties set
+ 1. TEST: run a query with coalesce with the valid value in different positions
+ tearDown: Remove the test contact inserted
+ """
+
+ query = """
+ SELECT tracker:coalesce (?nickname, ?family, ?full, ?note, 'test_coalesce') WHERE {
+ ?c a nco:IMContact .
+ OPTIONAL { ?c nco:fullname ?full }
+ OPTIONAL { ?c nco:nameFamily ?family }
+ OPTIONAL { ?c nco:nickname ?nickname }
+ OPTIONAL { ?c nco:note ?note }
+ }
+ """
+ results = self.resources.SparqlQuery (query)
+ assert results[0][0] == "family name"
+
+
+ def test_coalesce_none_fine_default (self):
+ """
+ setUp: Insert a contact with only some text properties set
+ 1. TEST: run a query with coalesce with the valid value in different positions
+ tearDown: Remove the test contact inserted
+ """
+
+ query = """
+ SELECT tracker:coalesce (?nickname, ?note, 'test_coalesce') WHERE {
+ ?c a nco:IMContact .
+ OPTIONAL { ?c nco:fullname ?full }
+ OPTIONAL { ?c nco:nameFamily ?family }
+ OPTIONAL { ?c nco:nickname ?nickname }
+ OPTIONAL { ?c nco:note ?note }
+ }
+ """
+ results = self.resources.SparqlQuery (query)
+ assert results[0][0] == "test_coalesce"
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/functional-tests/tests.xml b/tests/functional-tests/tests.xml
index df3ddbe..6131b01 100644
--- a/tests/functional-tests/tests.xml
+++ b/tests/functional-tests/tests.xml
@@ -33,6 +33,12 @@
<step expected_result="0">. /tmp/session_bus_address.user; python2.5 /usr/share/tracker-tests/04-group-concat.py</step>
</case>
+ <case name="test_coalesce" type="Functional" level="Feature"
+ description="Group concat function in sparql" requirement="01" subfeature="">
+ <!-- dbus env variables defined here. This works. -->
+ <step expected_result="0">. /tmp/session_bus_address.user; python2.5 /usr/share/tracker-tests/05-coalesce.py</step>
+ </case>
+
<!-- Environments optional - tells where the tests are run -->
<environments>
<scratchbox>true</scratchbox>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]