Merge lp:~mandel/desktopcouch/improve_keyring_tests into lp:desktopcouch

Proposed by Manuel de la Peña on 2010-11-01
Status: Merged
Approved by: Manuel de la Peña on 2011-01-04
Approved revision: 196
Merged at revision: 243
Proposed branch: lp:~mandel/desktopcouch/improve_keyring_tests
Merge into: lp:desktopcouch
Prerequisite: lp:~mandel/desktopcouch/move_xdg_to_platform
Diff against target: 204 lines (+194/-0)
2 files modified
desktopcouch/application/platform/linux/tests/__init__.py (+1/-0)
desktopcouch/application/platform/linux/tests/test_keyring.py (+193/-0)
To merge this branch: bzr merge lp:~mandel/desktopcouch/improve_keyring_tests
Reviewer Review Type Date Requested Status
Vincenzo Di Somma (community) Approve on 2010-11-02
Eric Casteleijn (community) 2010-11-01 Approve on 2010-11-02
Review via email: mp+39800@code.launchpad.net

Commit Message

Increase the test coverage of the Keyring class that uses gnomekeyring as its backend.

Description of the Change

Increase the test coverage of the Keyring class that uses gnomekeyring as its backed.

To post a comment you must log in.
Eric Casteleijn (thisfred) wrote :

The amount of awesome is overwhelming today.

review: Approve
Vincenzo Di Somma (vds) :
review: Approve
dobey (dobey) wrote :

The prerequisite lp:~mandel/desktopcouch/move_xdg_to_platform has not yet been merged into lp:desktopcouch.

Ubuntu One Auto Pilot (otto-pilot) wrote :
Ubuntu One Auto Pilot (otto-pilot) wrote :

Attempt to merge into lp:desktopcouch failed due to conflicts:

text conflict in desktopcouch/application/platform/linux/keyring.py

Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (28.7 KiB)

The attempt to merge lp:~mandel/desktopcouch/improve_keyring_tests into lp:desktopcouch failed. Below is the output from the failed tests.

Apache CouchDB has started, time to relax.
Browse your desktop CouchDB at file:///tmp/tmpDLcJxq/data/couchdb.html
desktopcouch.application.tests.test_start_local_couchdb
  TestUpdateDesignDocuments
    test_create_databases_and_design_docs ... [OK]
desktopcouch.application.tests.test_service
  TestService
    test_start_desktopcouch_replication ... [OK]
    test_start_new_desktopcouch_extensions ... [OK]
    test_start_new_desktopcouch_no_extensions ... [OK]
desktopcouch.application.tests.test_local_files
  TestKeyringIntegration
    test_with_auth ... [OK]
    test_with_no_auth ... [OK]
  TestLocalFiles
    test_all_files_returned ... [OK]
    test_bind_address ... [OK]
    test_couch_chain_ini_files ... [OK]
    test_xdg_overwrite_works ... [OK]
desktopcouch.application.tests.test_replication
  TestReplication
    test_creation ... Apache CouchDB has started, time to relax.
Browse your desktop CouchDB at file:///tmp/tmpPj_Wtg/data/couchdb.html
                                                     [OK]
  TestUbuntuoneReplication
    test_exclusion ... Apache CouchDB has started, time to relax.
Browse your desktop CouchDB at file:///tmp/tmpZo6fyl/data/couchdb.html
                                                    [OK]
desktopcouch.application.migration.tests.test_migration
  TestMigration
    test_migration_deleted_flag_to_trash ... test_migration_deleted_flag_to_trash
apple
                              [OK]
    test_migration_script_is_run ... test_migration_script_is_run
                                      [OK]
    test_migration_script_is_run_and_can_access_view ... test_migration_script_is_run_and_can_access_view
                  [OK]
  TestRegistration
    test_register_migration_is_added_to_the_registry ... [OK]
desktopcouch.application.platform.linux.tests.test_keyring
  TestGnomeKeyring
    test_get_aouth_no_keyring ... Traceback (most recent call last):
  File "/usr/lib/python2.7/unittest/case.py", line 311, in run
    self.setUp()
  File "/var/cache/tarmac/desktopcouch/trunk/desktopcouch/application/platform/linux/tests/test_keyring.py", line 33, in setUp
    keyring=self._gnomekeyring)
exceptions.TypeError: __init__() got an unexpected keyword argument 'make_random_string'
[ERROR]
    test_get_oauth_canceled_store ... Traceback (most recent call last):
  File "/usr/lib/python2.7/unittest/case.py", line 311, in run
    self.setUp()
  File "/var/cache/tarmac/desktopcouch/trunk/desktopcouch/application/platform/linux/tests/test_keyring.py", line 33, in setUp
    keyring=self._gnomekeyring)
exceptions.TypeError: __init__() got an unexpected keyword argument 'make_random_string'
[ERROR]
    test_...

Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (28.9 KiB)

The attempt to merge lp:~mandel/desktopcouch/improve_keyring_tests into lp:desktopcouch failed. Below is the output from the failed tests.

Apache CouchDB has started, time to relax.
Browse your desktop CouchDB at file:///tmp/tmp1lBCOH/data/couchdb.html
desktopcouch.application.tests.test_start_local_couchdb
  TestUpdateDesignDocuments
    test_create_databases_and_design_docs ... [OK]
desktopcouch.application.tests.test_service
  TestService
    test_start_desktopcouch_replication ... [OK]
    test_start_new_desktopcouch_extensions ... [OK]
    test_start_new_desktopcouch_no_extensions ... [OK]
desktopcouch.application.tests.test_local_files
  TestKeyringIntegration
    test_with_auth ... [OK]
    test_with_no_auth ... [OK]
  TestLocalFiles
    test_all_files_returned ... [OK]
    test_bind_address ... [OK]
    test_couch_chain_ini_files ... [OK]
    test_xdg_overwrite_works ... [OK]
desktopcouch.application.tests.test_replication
  TestReplication
    test_creation ... Apache CouchDB has started, time to relax.
Browse your desktop CouchDB at file:///tmp/tmpnrtXSs/data/couchdb.html
                                                     [OK]
  TestUbuntuoneReplication
    test_exclusion ... Apache CouchDB has started, time to relax.
Browse your desktop CouchDB at file:///tmp/tmp69ks0D/data/couchdb.html
                                                    [OK]
desktopcouch.application.migration.tests.test_migration
  TestMigration
    test_migration_deleted_flag_to_trash ... test_migration_deleted_flag_to_trash
apple
                              [OK]
    test_migration_script_is_run ... test_migration_script_is_run
                                      [OK]
    test_migration_script_is_run_and_can_access_view ... test_migration_script_is_run_and_can_access_view
                  [OK]
  TestRegistration
    test_register_migration_is_added_to_the_registry ... [OK]
desktopcouch.application.platform.linux.tests.test_keyring
  TestGnomeKeyring
    test_get_aouth_no_keyring ... [OK]
    test_get_oauth_canceled_store ... [OK]
    test_get_oauth_data_stored ... [OK]
    test_get_user_name_password_keyring ... [OK]
    test_get_user_name_password_no_daemon ... [OK]
    test_get_user_name_password_not_in_keyring ... [OK]
    test_get_user_name_password_user_cancel ... [OK]
desktopcouch.application.platform.windows.tests.test_keyring
  TestKeyring
    test_get_oauth_data ... [OK]
    test_get_user_name_password ... [OK]
    test_get_user_name_passw...

196. By Manuel de la Peña on 2011-01-03

Merged with trunk, fixed lint and pep8 warnings.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'desktopcouch/application/platform/linux/tests'
2=== added file 'desktopcouch/application/platform/linux/tests/__init__.py'
3--- desktopcouch/application/platform/linux/tests/__init__.py 1970-01-01 00:00:00 +0000
4+++ desktopcouch/application/platform/linux/tests/__init__.py 2011-01-04 17:08:43 +0000
5@@ -0,0 +1,1 @@
6+"""Test the linux platform code."""
7
8=== added file 'desktopcouch/application/platform/linux/tests/test_keyring.py'
9--- desktopcouch/application/platform/linux/tests/test_keyring.py 1970-01-01 00:00:00 +0000
10+++ desktopcouch/application/platform/linux/tests/test_keyring.py 2011-01-04 17:08:43 +0000
11@@ -0,0 +1,193 @@
12+# Copyright 2009 Canonical Ltd.
13+#
14+# This file is part of desktopcouch.
15+#
16+# desktopcouch is free software: you can redistribute it and/or modify
17+# it under the terms of the GNU Lesser General Public License version 3
18+# as published by the Free Software Foundation.
19+#
20+# desktopcouch is distributed in the hope that it will be useful,
21+# but WITHOUT ANY WARRANTY; without even the implied warranty of
22+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23+# GNU Lesser General Public License for more details.
24+#
25+# You should have received a copy of the GNU Lesser General Public License
26+# along with desktopcouch. If not, see <http://www.gnu.org/licenses/>.
27+#
28+# Author: Manuel de la Pena <manuel.delapena@canonical.com>
29+"""Test the linux keyring implementation."""
30+from mocker import MockerTestCase, ANY
31+
32+import gnomekeyring
33+
34+from desktopcouch.application.platform.linux.keyring import Keyring
35+
36+
37+# pylint: disable=W0104
38+class TestGnomeKeyring(MockerTestCase):
39+ """Test the interaction with the gnome keyring."""
40+
41+ def setUp(self):
42+ super(TestGnomeKeyring, self).setUp()
43+ self._gnomekeyring = self.mocker.mock()
44+ self._random_string = self.mocker.mock()
45+ self._data = self.mocker.mock()
46+ self._keyring = Keyring(make_random_string_fn=self._random_string,
47+ keyring=self._gnomekeyring)
48+
49+ def test_get_user_name_password_keyring(self):
50+ """Test the retrieval of the data when is present in the ring."""
51+ user_name = 'mandel'
52+ password = 'test'
53+ self._gnomekeyring.ITEM_GENERIC_SECRET
54+ self.mocker.result(0)
55+ self._gnomekeyring.find_items_sync(0, {'desktopcouch': 'basic'})
56+ self.mocker.result(self._data)
57+ self._data[0].secret
58+ self.mocker.result("%s:%s" % (user_name, password))
59+ self.mocker.replay()
60+ result_user, result_pass = self._keyring.get_user_name_password()
61+ self.assertEqual(result_user, user_name)
62+ self.assertEqual(result_pass, password)
63+
64+ def test_get_user_name_password_not_in_keyring(self):
65+ """Test the retrieval of the data when missing from the ring."""
66+ user_name = 'mandel'
67+ password = 'test'
68+ self._gnomekeyring.ITEM_GENERIC_SECRET
69+ self.mocker.result(0)
70+ self._gnomekeyring.find_items_sync(0, {'desktopcouch': 'basic'})
71+ self.mocker.throw(gnomekeyring.NoMatchError)
72+ self._random_string(10)
73+ self.mocker.result(user_name)
74+ self._random_string(10)
75+ self.mocker.result(password)
76+ self._gnomekeyring.item_create_sync(None, 0, ANY,
77+ {'desktopcouch': 'basic'}, "%s:%s" % (user_name, password), True)
78+ self.mocker.replay()
79+ result_user, result_pass = self._keyring.get_user_name_password()
80+ self.assertEqual(result_user, user_name)
81+ self.assertEqual(result_pass, password)
82+
83+ def test_get_user_name_password_user_cancel(self):
84+ """Test the retrieva of the data when the user denies the access."""
85+ user_name = 'mandel'
86+ password = 'test'
87+ self._gnomekeyring.ITEM_GENERIC_SECRET
88+ self.mocker.result(0)
89+ self._gnomekeyring.find_items_sync(0, {'desktopcouch': 'basic'})
90+ self.mocker.throw(gnomekeyring.NoMatchError)
91+ self._random_string(10)
92+ self.mocker.result(user_name)
93+ self._random_string(10)
94+ self.mocker.result(password)
95+ self._gnomekeyring.item_create_sync(None, 0, ANY,
96+ {'desktopcouch': 'basic'}, "%s:%s" % (user_name, password), True)
97+ self.mocker.throw(gnomekeyring.NoKeyringDaemonError)
98+ self.mocker.replay()
99+ result_user, result_pass = self._keyring.get_user_name_password()
100+ self.assertEqual(result_user, user_name)
101+ self.assertEqual(result_pass, password)
102+
103+ def test_get_user_name_password_no_daemon(self):
104+ """Test the retrieval when the keyring daemon is not running."""
105+ user_name = 'mandel'
106+ password = 'test'
107+ self._gnomekeyring.ITEM_GENERIC_SECRET
108+ self.mocker.result(0)
109+ self._gnomekeyring.find_items_sync(0, {'desktopcouch': 'basic'})
110+ self.mocker.throw(gnomekeyring.NoMatchError)
111+ self._random_string(10)
112+ self.mocker.result(user_name)
113+ self._random_string(10)
114+ self.mocker.result(password)
115+ self._gnomekeyring.item_create_sync(None, 0, ANY,
116+ {'desktopcouch': 'basic'}, "%s:%s" % (user_name, password), True)
117+ self.mocker.throw(gnomekeyring.NoKeyringDaemonError)
118+ self.mocker.replay()
119+ result_user, result_pass = self._keyring.get_user_name_password()
120+ self.assertEqual(result_user, user_name)
121+ self.assertEqual(result_pass, password)
122+
123+ def test_get_oauth_data_stored(self):
124+ """Test the storeage of the oath data."""
125+ consumer_key = 'consumer_key'
126+ consumer_secret = 'consumer_secret'
127+ token = 'token'
128+ token_secret = 'token_secret'
129+ self._random_string(10)
130+ self.mocker.result(consumer_key)
131+ self._random_string(10)
132+ self.mocker.result(consumer_secret)
133+ self._random_string(10)
134+ self.mocker.result(token)
135+ self._random_string(10)
136+ self.mocker.result(token_secret)
137+ self._gnomekeyring.item_create_sync(
138+ None, ANY, ANY,
139+ {'desktopcouch': 'oauth'},
140+ "%s:%s:%s:%s" %
141+ (consumer_key, consumer_secret, token, token_secret), True)
142+ self.mocker.replay()
143+ result_consumer_key, result_consumer_secret, result_token, \
144+ result_token_secret = self._keyring.get_oauth_data()
145+ self.assertEqual(consumer_key, result_consumer_key)
146+ self.assertEqual(consumer_secret, result_consumer_secret)
147+ self.assertEqual(token, result_token)
148+ self.assertEqual(token_secret, result_token_secret)
149+
150+ def test_get_aouth_no_keyring(self):
151+ """Test the retrieval of the oauth data without a keyring."""
152+ consumer_key = 'consumer_key'
153+ consumer_secret = 'consumer_secret'
154+ token = 'token'
155+ token_secret = 'token_secret'
156+ self._random_string(10)
157+ self.mocker.result(consumer_key)
158+ self._random_string(10)
159+ self.mocker.result(consumer_secret)
160+ self._random_string(10)
161+ self.mocker.result(token)
162+ self._random_string(10)
163+ self.mocker.result(token_secret)
164+ self._gnomekeyring.item_create_sync(
165+ None, ANY, ANY,
166+ {'desktopcouch': 'oauth'},
167+ "%s:%s:%s:%s" %
168+ (consumer_key, consumer_secret, token, token_secret), True)
169+ self.mocker.throw(gnomekeyring.NoKeyringDaemonError)
170+ self.mocker.replay()
171+ result_consumer_key, result_consumer_secret, result_token, \
172+ result_token_secret = self._keyring.get_oauth_data()
173+ self.assertEqual(consumer_key, result_consumer_key)
174+ self.assertEqual(consumer_secret, result_consumer_secret)
175+ self.assertEqual(token, result_token)
176+ self.assertEqual(token_secret, result_token_secret)
177+
178+ def test_get_oauth_canceled_store(self):
179+ """Test the retrieval of the oauth data when the user cancels it."""
180+ consumer_key = 'consumer_key'
181+ consumer_secret = 'consumer_secret'
182+ token = 'token'
183+ token_secret = 'token_secret'
184+ self._random_string(10)
185+ self.mocker.result(consumer_key)
186+ self._random_string(10)
187+ self.mocker.result(consumer_secret)
188+ self._random_string(10)
189+ self.mocker.result(token)
190+ self._random_string(10)
191+ self.mocker.result(token_secret)
192+ self._gnomekeyring.item_create_sync(
193+ None, ANY, ANY,
194+ {'desktopcouch': 'oauth'},
195+ "%s:%s:%s:%s" %
196+ (consumer_key, consumer_secret, token, token_secret), True)
197+ self.mocker.throw(gnomekeyring.CancelledError)
198+ self.mocker.replay()
199+ result_consumer_key, result_consumer_secret, result_token, \
200+ result_token_secret = self._keyring.get_oauth_data()
201+ self.assertEqual(consumer_key, result_consumer_key)
202+ self.assertEqual(consumer_secret, result_consumer_secret)
203+ self.assertEqual(token, result_token)
204+ self.assertEqual(token_secret, result_token_secret)

Subscribers

People subscribed via source and target branches