Merge lp:~canonical-platform-qa/address-book-service/test_dummy_service into lp:address-book-service

Proposed by Omer Akram
Status: Merged
Approved by: Renato Araujo Oliveira Filho
Approved revision: 138
Merged at revision: 131
Proposed branch: lp:~canonical-platform-qa/address-book-service/test_dummy_service
Merge into: lp:address-book-service
Diff against target: 295 lines (+248/-0)
8 files modified
debian/address-book-service-testability.install (+2/-0)
debian/control (+9/-0)
tests/address_book_service_testability/__init__.py (+18/-0)
tests/address_book_service_testability/fixture_setup.py (+116/-0)
tests/address_book_service_testability/helpers.py (+42/-0)
tests/address_book_service_testability/tests/__init__.py (+18/-0)
tests/address_book_service_testability/tests/test_dummy_backend.py (+36/-0)
tests/data/vcard.vcf (+7/-0)
To merge this branch: bzr merge lp:~canonical-platform-qa/address-book-service/test_dummy_service
Reviewer Review Type Date Requested Status
Renato Araujo Oliveira Filho (community) Approve
Brendan Donegan (community) Approve
PS Jenkins bot continuous-integration Approve
Leo Arias (community) code review Approve
Review via email: mp+225846@code.launchpad.net

Commit message

add a test to ensure the dummy backend is working.

Description of the change

add a test to ensure the dummy backend is working so that other projects can rely on it. All the code in fixture_setup is written in such a way so that it can be easily consumed by other projects.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Leo Arias (elopio) wrote :

om26er: on SetupEnvironmentVariable, it's not clear that you can also set up some demo data.
I have no idea how to make it clear with code, so a docstring for the class is probably a good idea.
om26er: I like your branch, I love these new testability packages in python.
om26er: who is the other one affected by this? brendan or richard?
I think it would be nice if you request a review from him, so you all agree on the strategy.

review: Approve (code review)
Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

I need to give this a proper test, but to start with there are a few flake8 warnings:

address_book_service/fixture_setup.py:41:1: W293 blank line contains whitespace
address_book_service/fixture_setup.py:59:1: W293 blank line contains whitespace
address_book_service/fixture_setup.py:79:1: W293 blank line contains whitespace
address_book_service/fixture_setup.py:105:1: W293 blank line contains whitespace
address_book_service/fixture_setup.py:110:1: W293 blank line contains whitespace

Nothing major, but may as well fix them at this stage

Also, please take the autopilot directory out of the equation, i.e. just have tests/address_book_service_testability. This code has nothing directly to do with Autopilot (fixtures can also be used in testtools based tests).

I would also be inclined to name the python module address_book_service_testability, to match with the package name. I know it's a bit long, but it's more confusing if the package and module names are different.

Apart from that I just need to give this a test and see how it works.

Thanks!

review: Needs Fixing
Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

Sorry, I've realised that there actually *is* an autopilot test case in here. This isn't a good idea though - you're testing the lower-level code via the higher level code. Your test may fail even if address-book-service doesn't break, for example if address-book-app changes in some way. This will cause a lot of difficulties and annoyance down the line. Try and write a new test which only uses address-book-service itself. I really want this code to land soon so I'll be happy to help with that.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) :
review: Needs Fixing
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

looks good to me. but I will leave the top approval for someone from quality team.

review: Approve
Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

Okay, top approve

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:137
http://jenkins.qa.ubuntu.com/job/address-book-service-ci/270/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-service-utopic-amd64-ci/42
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-service-utopic-armhf-ci/42
        deb: http://jenkins.qa.ubuntu.com/job/address-book-service-utopic-armhf-ci/42/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-service-utopic-i386-ci/42
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/2507
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/2023/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/2657
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/3750
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/3750/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/10434
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/1692/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2276
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2276/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/address-book-service-ci/270/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:137
http://jenkins.qa.ubuntu.com/job/address-book-service-ci/271/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-service-utopic-amd64-ci/43
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-service-utopic-armhf-ci/43
        deb: http://jenkins.qa.ubuntu.com/job/address-book-service-utopic-armhf-ci/43/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-service-utopic-i386-ci/43
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/2725
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/2170/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/2829
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/3968
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/3968/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/10684
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/1802/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2429
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2429/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/address-book-service-ci/271/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

This needs to pass CI before landing. I don't know will this help fix the issue, but I did notice the following:

1.) address-book-service-testability doesn't need to depend on address-book-app-autopilot
2.) Architecture should be all, not any, and remove the Multi-arch field - this package contains no built binaries so doesn't need to be arch specific.

review: Needs Fixing
138. By Brendan Donegan

Make address-book-service-testability arch any and remove address-book-app-autopilot dependency

Revision history for this message
Omer Akram (om26er) wrote :

The ci failure is a problem with otto, not something in our control. it
expects the package to be in ubuntu archives, which its not.

On Thursday, July 31, 2014, Brendan Donegan <email address hidden>
wrote:
> Review: Needs Fixing
>
> This needs to pass CI before landing. I don't know will this help fix the
issue, but I did notice the following:
>
> 1.) address-book-service-testability doesn't need to depend on
address-book-app-autopilot
> 2.) Architecture should be all, not any, and remove the Multi-arch field
- this package contains no built binaries so doesn't need to be arch
specific.
> --
>
https://code.launchpad.net/~canonical-platform-qa/address-book-service/test_dummy_service/+merge/225846
> You proposed
lp:~canonical-platform-qa/address-book-service/test_dummy_service for
merging.
>

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:137
http://jenkins.qa.ubuntu.com/job/address-book-service-ci/272/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/address-book-service-utopic-amd64-ci/44/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-service-utopic-armhf-ci/44
        deb: http://jenkins.qa.ubuntu.com/job/address-book-service-utopic-armhf-ci/44/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-service-utopic-i386-ci/44
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/2762
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/2203/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/2854
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/4005
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/4005/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/10717
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/1824/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2462
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2462/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/address-book-service-ci/272/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:138
http://jenkins.qa.ubuntu.com/job/address-book-service-ci/273/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-service-utopic-amd64-ci/45
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-service-utopic-armhf-ci/45
        deb: http://jenkins.qa.ubuntu.com/job/address-book-service-utopic-armhf-ci/45/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-service-utopic-i386-ci/45
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/2773
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/2214
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/2864
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/4016
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/4016/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/10728
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/1834
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2473
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2473/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/address-book-service-ci/273/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:137
http://jenkins.qa.ubuntu.com/job/address-book-service-ci/274/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-service-utopic-amd64-ci/46
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-service-utopic-armhf-ci/46
        deb: http://jenkins.qa.ubuntu.com/job/address-book-service-utopic-armhf-ci/46/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-service-utopic-i386-ci/46
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/2780
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/2220
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/2870
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/4023
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/4023/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/10734
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/1838
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2479
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2479/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/address-book-service-ci/274/rebuild

review: Approve (continuous-integration)
Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

Ok this can be top approved and landed now

review: Approve
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

Are there any related MPs required for this MP to build/function as expected? NO

Is your branch in sync with latest trunk? YES

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator? YES

Did you successfully run all tests found in your component's Test Plan on device or emulator? YES

If you changed the UI, was the change specified/approved by design? NO UI CHANGE
If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP? NO PACKAGE CHANGE

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'debian/address-book-service-testability.install'
2--- debian/address-book-service-testability.install 1970-01-01 00:00:00 +0000
3+++ debian/address-book-service-testability.install 2014-07-30 19:09:13 +0000
4@@ -0,0 +1,2 @@
5+tests/address_book_service_testability /usr/lib/python3/dist-packages
6+tests/data/vcard.vcf /usr/share/address-book-service/data
7
8=== modified file 'debian/control'
9--- debian/control 2014-03-27 15:24:10 +0000
10+++ debian/control 2014-07-30 19:09:13 +0000
11@@ -38,6 +38,15 @@
12 A fork of folks dummy backend to be used as standalone backend to test address-book-service.
13
14
15+Package: address-book-service-testability
16+Architecture: all
17+Depends: ${misc:Depends},
18+ ${shlibs:Depends},
19+ address-book-service-dummy,
20+Description: Low-level tests for dummy-backend
21+ Tests to ensure the dummy backend keeps functioning.
22+
23+
24 Package: qtcontact5-galera
25 Architecture: any
26 Multi-Arch: same
27
28=== added directory 'tests/address_book_service_testability'
29=== added file 'tests/address_book_service_testability/__init__.py'
30--- tests/address_book_service_testability/__init__.py 1970-01-01 00:00:00 +0000
31+++ tests/address_book_service_testability/__init__.py 2014-07-30 19:09:13 +0000
32@@ -0,0 +1,18 @@
33+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
34+#
35+# Copyright (C) 2014 Canonical
36+# Author: Omer Akram <omer.akram@canonical.com>
37+#
38+# This program is free software: you can redistribute it and/or modify
39+# it under the terms of the GNU General Public License as published by
40+# the Free Software Foundation, either version 3 of the License, or
41+# (at your option) any later version.
42+#
43+# This program is distributed in the hope that it will be useful,
44+# but WITHOUT ANY WARRANTY; without even the implied warranty of
45+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46+# GNU General Public License for more details.
47+#
48+# You should have received a copy of the GNU General Public License
49+# along with this program. If not, see <http://www.gnu.org/licenses/>.
50+#
51
52=== added file 'tests/address_book_service_testability/fixture_setup.py'
53--- tests/address_book_service_testability/fixture_setup.py 1970-01-01 00:00:00 +0000
54+++ tests/address_book_service_testability/fixture_setup.py 2014-07-30 19:09:13 +0000
55@@ -0,0 +1,116 @@
56+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
57+#
58+# Copyright (C) 2014 Canonical
59+# Author: Omer Akram <omer.akram@canonical.com>
60+#
61+# This program is free software: you can redistribute it and/or modify
62+# it under the terms of the GNU General Public License as published by
63+# the Free Software Foundation, either version 3 of the License, or
64+# (at your option) any later version.
65+#
66+# This program is distributed in the hope that it will be useful,
67+# but WITHOUT ANY WARRANTY; without even the implied warranty of
68+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
69+# GNU General Public License for more details.
70+#
71+# You should have received a copy of the GNU General Public License
72+# along with this program. If not, see <http://www.gnu.org/licenses/>.
73+#
74+
75+import os
76+import subprocess
77+import sysconfig
78+import time
79+
80+from fixtures import EnvironmentVariable, Fixture
81+
82+
83+def get_service_library_path():
84+ """Return path of address-book-service binary directory."""
85+ architecture = sysconfig.get_config_var('MULTIARCH')
86+
87+ return os.path.join(
88+ '/usr/lib/',
89+ architecture,
90+ 'address-book-service/')
91+
92+
93+class AddressBookServiceDummyBackend(Fixture):
94+ """Fixture to load test vcard for client applications
95+
96+ Call the fixture without any paramter to load a default vcard
97+
98+ :parameter vcard: call the fixture with a vcard to be used by
99+ test application.
100+
101+ """
102+ def __init__(self, vcard=None):
103+ self.contact_data = vcard
104+
105+ def setUp(self):
106+ super(AddressBookServiceDummyBackend, self).setUp()
107+ self.useFixture(SetupEnvironmentVariables(self.contact_data))
108+ self.useFixture(RestartService())
109+
110+
111+class SetupEnvironmentVariables(Fixture):
112+
113+ def __init__(self, vcard):
114+ self.vcard = vcard
115+
116+ def setUp(self):
117+ super(SetupEnvironmentVariables, self).setUp()
118+ self._setup_environment()
119+
120+ def _setup_environment(self):
121+ self.useFixture(EnvironmentVariable(
122+ 'ALTERNATIVE_CPIM_SERVICE_NAME', 'com.canonical.test.pim'))
123+ self.useFixture(EnvironmentVariable(
124+ 'FOLKS_BACKEND_PATH',
125+ os.path.join(get_service_library_path(), 'dummy.so')))
126+ self.useFixture(EnvironmentVariable('FOLKS_BACKENDS_ALLOWED', 'dummy'))
127+ self.useFixture(EnvironmentVariable('FOLKS_PRIMARY_STORE', 'dummy'))
128+ self.useFixture(EnvironmentVariable(
129+ 'ADDRESS_BOOK_SERVICE_DEMO_DATA',
130+ self._get_vcard_location()))
131+
132+ def _get_vcard_location(self):
133+ if self.vcard:
134+ return self.vcard
135+
136+ local_location = os.path.abspath('vcard.vcf')
137+ bin_location = '/usr/share/address-book-service/data/vcard.vcf'
138+ if os.path.exists(local_location):
139+ return local_location
140+ elif os.path.exists(bin_location):
141+ return bin_location
142+ else:
143+ raise RuntimeError('No VCARD found.')
144+
145+
146+class RestartService(Fixture):
147+
148+ def setUp(self):
149+ super(RestartService, self).setUp()
150+ self.addCleanup(self._kill_address_book_service)
151+ self._restart_address_book_service()
152+
153+ def _kill_address_book_service(self):
154+ try:
155+ pid = subprocess.check_output(
156+ ['pidof', 'address-book-service']).strip()
157+ subprocess.call(['kill', '-3', pid])
158+ except subprocess.CalledProcessError:
159+ # Service not running, so do nothing.
160+ pass
161+
162+ def _restart_address_book_service(self):
163+ self._kill_address_book_service()
164+ path = os.path.join(
165+ get_service_library_path(), 'address-book-service')
166+
167+ subprocess.Popen([path])
168+ # FIXME: Wait for 5 seconds before proceeding so that the
169+ # service starts,doing this because the dbus interface is
170+ # not reliable enough it seems. --om26er 23-07-2014
171+ time.sleep(5)
172
173=== added file 'tests/address_book_service_testability/helpers.py'
174--- tests/address_book_service_testability/helpers.py 1970-01-01 00:00:00 +0000
175+++ tests/address_book_service_testability/helpers.py 2014-07-30 19:09:13 +0000
176@@ -0,0 +1,42 @@
177+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
178+#
179+# Copyright 2014 Canonical Ltd.
180+#
181+# This file is part of address-book-service tests.
182+#
183+# This program is free software; you can redistribute it and/or modify
184+# it under the terms of the GNU General Public License version 3, as published
185+# by the Free Software Foundation.
186+#
187+# This program is distributed in the hope that it will be useful,
188+# but WITHOUT ANY WARRANTY; without even the implied warranty of
189+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
190+# GNU General Public License for more details.
191+#
192+# You should have received a copy of the GNU General Public License
193+# along with this program. If not, see <http://www.gnu.org/licenses/>
194+
195+import dbus
196+
197+DBUS_IFACE_ADD_BOOK = 'com.canonical.pim.AddressBook'
198+DBUS_IFACE_ADD_BOOKVIEW = 'com.canonical.pim.AddressBookView'
199+
200+bus = dbus.SessionBus()
201+
202+
203+def query_contacts(fields='', query='', sources=[]):
204+ iface = _get_contacts_dbus_service_iface()
205+ view_path = iface.query(fields, query, [])
206+ view = bus.get_object(
207+ 'com.canonical.pim', view_path)
208+ view_iface = dbus.Interface(
209+ view, dbus_interface=DBUS_IFACE_ADD_BOOKVIEW)
210+ contacts = view_iface.contactsDetails([], 0, -1)
211+ view.close()
212+ return contacts
213+
214+
215+def _get_contacts_dbus_service_iface():
216+ proxy = bus.get_object(
217+ 'com.canonical.pim', '/com/canonical/pim/AddressBook')
218+ return dbus.Interface(proxy, 'com.canonical.pim.AddressBook')
219
220=== added directory 'tests/address_book_service_testability/tests'
221=== added file 'tests/address_book_service_testability/tests/__init__.py'
222--- tests/address_book_service_testability/tests/__init__.py 1970-01-01 00:00:00 +0000
223+++ tests/address_book_service_testability/tests/__init__.py 2014-07-30 19:09:13 +0000
224@@ -0,0 +1,18 @@
225+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
226+#
227+# Copyright (C) 2014 Canonical
228+# Author: Omer Akram <omer.akram@canonical.com>
229+#
230+# This program is free software: you can redistribute it and/or modify
231+# it under the terms of the GNU General Public License as published by
232+# the Free Software Foundation, either version 3 of the License, or
233+# (at your option) any later version.
234+#
235+# This program is distributed in the hope that it will be useful,
236+# but WITHOUT ANY WARRANTY; without even the implied warranty of
237+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
238+# GNU General Public License for more details.
239+#
240+# You should have received a copy of the GNU General Public License
241+# along with this program. If not, see <http://www.gnu.org/licenses/>.
242+#
243
244=== added file 'tests/address_book_service_testability/tests/test_dummy_backend.py'
245--- tests/address_book_service_testability/tests/test_dummy_backend.py 1970-01-01 00:00:00 +0000
246+++ tests/address_book_service_testability/tests/test_dummy_backend.py 2014-07-30 19:09:13 +0000
247@@ -0,0 +1,36 @@
248+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
249+#
250+# Copyright (C) 2014 Canonical
251+# Author: Omer Akram <omer.akram@canonical.com>
252+#
253+# This program is free software: you can redistribute it and/or modify
254+# it under the terms of the GNU General Public License as published by
255+# the Free Software Foundation, either version 3 of the License, or
256+# (at your option) any later version.
257+#
258+# This program is distributed in the hope that it will be useful,
259+# but WITHOUT ANY WARRANTY; without even the implied warranty of
260+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
261+# GNU General Public License for more details.
262+#
263+# You should have received a copy of the GNU General Public License
264+# along with this program. If not, see <http://www.gnu.org/licenses/>.
265+#
266+
267+import testtools
268+
269+from address_book_service_testability import fixture_setup, helpers
270+
271+
272+class DummyBackendTestCase(testtools.TestCase):
273+ """tests for the dummy backend of contacts service."""
274+
275+ def setUp(self):
276+ dummy_backend = fixture_setup.AddressBookServiceDummyBackend()
277+ self.useFixture(dummy_backend)
278+ super(DummyBackendTestCase, self).setUp()
279+
280+ def test_dummy_backend_loads_vcard(self):
281+ """Makes sure the dummy backend is loading the vcard."""
282+ contacts = str(helpers.query_contacts())
283+ self.assertTrue('UX User' in contacts, True)
284
285=== added file 'tests/data/vcard.vcf'
286--- tests/data/vcard.vcf 1970-01-01 00:00:00 +0000
287+++ tests/data/vcard.vcf 2014-07-30 19:09:13 +0000
288@@ -0,0 +1,7 @@
289+BEGIN:VCARD
290+VERSION:3.0
291+N:User;UX;
292+FN:UX User
293+TEL:3333333
294+END:VCARD
295+

Subscribers

People subscribed via source and target branches