[tracker] Tests: Functional test for group concat
- From: Ivan Frade <ifrade src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker] Tests: Functional test for group concat
- Date: Tue, 2 Feb 2010 16:35:47 +0000 (UTC)
commit 5de5bae794989b502028c936b9445b70374df76d
Author: Ivan Frade <ivan frade nokia com>
Date: Tue Feb 2 18:10:52 2010 +0200
Tests: Functional test for group concat
tests/functional-tests/04-group-concat.py | 98 +++++++++++++++++++++++++++++
tests/functional-tests/tests.xml | 6 ++
2 files changed, 104 insertions(+), 0 deletions(-)
---
diff --git a/tests/functional-tests/04-group-concat.py b/tests/functional-tests/04-group-concat.py
new file mode 100644
index 0000000..9a28052
--- /dev/null
+++ b/tests/functional-tests/04-group-concat.py
@@ -0,0 +1,98 @@
+#!/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 TestGroupConcat (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_group_concat (self):
+ """
+ 1. Insert 3 capabilities for a test contact
+ 2. Retrieve contact/capabilites without group_contact (3 results)
+ 2. TEST: contact with group_concat capabilities (1 result)
+ 3. Remove the test contact inserted
+ """
+
+ uri = "contact://test_group_concat"
+
+ insert = """
+ INSERT { <%s> a nco:IMContact;
+ nco:fullname \"test_group_concat\";
+ nco:imContactCapability nco:im-capability-text-chat ;
+ nco:imContactCapability nco:im-capability-media-calls ;
+ nco:imContactCapability nco:im-capability-file-transfers .
+ }
+ """ % (uri)
+ self.resources.SparqlUpdate (insert)
+
+ query = """
+ SELECT ?c ?capability WHERE {
+ ?c a nco:IMContact ;
+ nco:fullname \"test_group_concat\";
+ nco:imContactCapability ?capability .
+ }
+ """
+ results = self.resources.SparqlQuery (query)
+
+ assert len (results) == 3
+ group_concat_query = """
+ SELECT ?c GROUP_CONCAT (?capability, '|') AS ?cap WHERE {
+ ?c a nco:IMContact ;
+ nco:fullname \"test_group_concat\";
+ nco:imContactCapability ?capability .
+ } GROUP BY (?c)
+ """
+ results = self.resources.SparqlQuery (group_concat_query)
+ assert len (results) == 1
+
+ instances = results[0][1].split ('|')
+ assert len (instances) == 3
+
+ TEXT_CHAT = "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#im-capability-text-chat"
+ MEDIA_CALLS = "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#im-capability-media-calls"
+ FILE_TRANSFERS = "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#im-capability-file-transfers"
+ assert TEXT_CHAT in instances
+ assert MEDIA_CALLS in instances
+ assert FILE_TRANSFERS in instances
+
+
+ #self.assertEquals (str(results[0][0]), "test_insertion_1")
+
+ delete = """
+ DELETE { <%s> a rdfs:Resource. }
+ """ % (uri)
+ self.resources.SparqlUpdate (delete)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/functional-tests/tests.xml b/tests/functional-tests/tests.xml
index be0c537..df3ddbe 100644
--- a/tests/functional-tests/tests.xml
+++ b/tests/functional-tests/tests.xml
@@ -27,6 +27,12 @@
<step expected_result="0">. /tmp/session_bus_address.user; python2.5 /usr/share/tracker-tests/03-fts-functions.py</step>
</case>
+ <case name="test_group_concat" 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/04-group-concat.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]