Merge lp:~mfisch/ubuntu-accomplishments-daemon/ubuntu-accomplishments-daemon-unittest-fixes into lp:ubuntu-accomplishments-daemon

Proposed by Matt Fischer
Status: Merged
Merged at revision: 106
Proposed branch: lp:~mfisch/ubuntu-accomplishments-daemon/ubuntu-accomplishments-daemon-unittest-fixes
Merge into: lp:ubuntu-accomplishments-daemon
Diff against target: 270 lines (+50/-26)
4 files modified
accomplishments/daemon/api.py (+14/-6)
accomplishments/daemon/tests/tests.py (+20/-18)
debian/control (+12/-2)
debian/rules (+4/-0)
To merge this branch: bzr merge lp:~mfisch/ubuntu-accomplishments-daemon/ubuntu-accomplishments-daemon-unittest-fixes
Reviewer Review Type Date Requested Status
Rafał Cieślak Pending
Review via email: mp+115201@code.launchpad.net

Description of the change

Final set of fixes for getting the unit tests running.

1) generate a default en_US locale
2) don't connect to SyncDaemon since we don't have dbus running (test_mode = True)

To post a comment you must log in.
106. By Matt Fischer

fixing merge conflict

107. By Matt Fischer

last fix?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'accomplishments/daemon/api.py'
2--- accomplishments/daemon/api.py 2012-07-16 16:22:10 +0000
3+++ accomplishments/daemon/api.py 2012-07-16 19:00:24 +0000
4@@ -316,7 +316,7 @@
5
6 No D-Bus required, so that it can be used for testing.
7 """
8- def __init__(self, service, show_notifications=None):
9+ def __init__(self, service, show_notifications=None, test_mode=False):
10 self.accomplishments_installpaths = None
11 self.trophies_path = None
12 self.has_u1 = False
13@@ -336,6 +336,7 @@
14 self.asyncapi = AsyncAPI(self)
15
16 self.scripts_queue = deque()
17+ self.test_mode = test_mode
18
19 try:
20 rootdir = os.environ['ACCOMPLISHMENTS_ROOT_DIR']
21@@ -375,11 +376,17 @@
22
23 self.show_notifications = show_notifications
24 log.msg("Connecting to Ubuntu One")
25- self.sd = SyncDaemonTool()
26+ if not self.test_mode:
27+ self.sd = SyncDaemonTool()
28+ else:
29+ log.msg("Test mode enabled, not connecting to SyncDaemonTool()")
30+ self.sd = None
31
32 self.reload_accom_database()
33-
34- self.sd.connect_signal("DownloadFinished", self._process_recieved_asc_file)
35+
36+ if not self.test_mode:
37+ self.sd.connect_signal("DownloadFinished", self._process_recieved_asc_file)
38+
39 self._create_all_trophy_icons()
40
41 self._refresh_share_data()
42@@ -583,8 +590,9 @@
43 self._write_config_file()
44
45 def _refresh_share_data(self):
46- l = self.sd.list_shared()
47- l.addCallback(self._complete_refreshing_share_data)
48+ if not self.test_mode:
49+ l = self.sd.list_shared()
50+ l.addCallback(self._complete_refreshing_share_data)
51
52 def _complete_refreshing_share_data(self,shares):
53 matchingshares = []
54
55=== modified file 'accomplishments/daemon/tests/tests.py'
56--- accomplishments/daemon/tests/tests.py 2012-07-13 23:00:12 +0000
57+++ accomplishments/daemon/tests/tests.py 2012-07-16 19:00:24 +0000
58@@ -152,7 +152,7 @@
59 self.util_copy_accomp(self.accomp_dir, "first")
60 self.util_copy_accomp(self.accomp_dir, "second")
61 self.util_copy_accomp(self.accomp_dir, "third")
62- a = api.Accomplishments(None)
63+ a = api.Accomplishments(None, None, True)
64
65 # get_acc_data
66 data = a.get_acc_data("%s/first" % self.ACCOMP_SET)
67@@ -256,7 +256,7 @@
68 self.assertRaises(KeyError, a.get_acc_categories, "wrong")
69
70 def test_get_block_ubuntuone_notification_bubbles(self):
71- a = api.Accomplishments(None)
72+ a = api.Accomplishments(None, None, True)
73 val = a.get_block_ubuntuone_notification_bubbles()
74 self.assertTrue(isinstance(val, bool))
75 # don't write the config file here because it's using U1's
76@@ -269,7 +269,7 @@
77 return
78
79 def test_get_daemon_session_start(self):
80- a = api.Accomplishments(None)
81+ a = api.Accomplishments(None, None, True)
82 val = a.get_daemon_session_start()
83 self.assertTrue(isinstance(val, bool))
84 a.write_config_file_item('config', 'daemon_sessionstart', False)
85@@ -282,7 +282,7 @@
86 return
87
88 def test_get_media_file(self):
89- a = api.Accomplishments(None)
90+ a = api.Accomplishments(None, None, True)
91 mf = a.get_media_file("non-existant.jpg")
92 self.assertTrue(mf == None)
93
94@@ -290,14 +290,14 @@
95 self.assertTrue(mf.endswith("lock.png"))
96
97 def test_get_API_version(self):
98- a = api.Accomplishments(None)
99+ a = api.Accomplishments(None, None, True)
100 version = a.get_API_version()
101 self.assertTrue(isinstance(version, basestring))
102
103 # also tests get_acc_icon_path
104 def test_get_acc_icon(self):
105 self.util_copy_accomp(self.accomp_dir, "first")
106- a = api.Accomplishments(None)
107+ a = api.Accomplishments(None, None, True)
108 self.assertEquals(a.get_acc_icon('%s/first' % self.ACCOMP_SET),
109 'first.jpg')
110 icon_path = a.get_acc_icon_path('%s/first' % self.ACCOMP_SET)
111@@ -307,7 +307,7 @@
112 self.util_remove_all_accomps(self.accomp_dir)
113 self.util_copy_accomp(self.accomp_dir, "first")
114 self.util_copy_accomp(self.accomp_dir, "second")
115- a = api.Accomplishments(None)
116+ a = api.Accomplishments(None, None, True)
117 viewer_db = a.build_viewer_database()
118 self.assertEquals(len(viewer_db), 2)
119
120@@ -339,7 +339,7 @@
121 self.util_copy_accomp(self.accomp_dir, "second")
122 self.util_copy_accomp(self.accomp_dir, "third")
123
124- a = api.Accomplishments(None)
125+ a = api.Accomplishments(None, None, True)
126 self.assertEqual(len(a.list_accomplishments()), 3)
127
128 # add a new accomp
129@@ -360,7 +360,7 @@
130
131 @unittest.skip("need the daemon running")
132 def test_accomplish(self):
133- a = api.Accomplishments(None)
134+ a = api.Accomplishments(None, None, True)
135 self.assertEqual(len(a.list_trophies()), 0)
136 a.accomplish("%s/first" % self.ACCOMP_SET)
137 trophies = a.list_trophies()
138@@ -369,7 +369,7 @@
139
140 def test_missing_about_file(self):
141 os.remove(os.path.join(self.accomp_root, "ABOUT"))
142- self.assertRaises(LookupError, api.Accomplishments, (None))
143+ self.assertRaises(LookupError, api.Accomplishments, None, None, True)
144
145 # put the file back
146 self.util_write_about_file(self.accomp_root)
147@@ -382,7 +382,7 @@
148 # ensure a clean start
149 self.util_remove_all_accomps(self.accomp_dir)
150 self.util_copy_accomp(self.accomp_dir, "first")
151- a = api.Accomplishments(None)
152+ a = api.Accomplishments(None, None, True)
153 self.assertEqual(len(a.list_accomplishments()), 1)
154 self.util_write_file(self.accomp_dir, "bad.accomplishment",
155 "[accomplishment]\n"\
156@@ -397,19 +397,21 @@
157 self.util_write_file(self.accomp_dir, "bad.accomplishment",
158 "[accomplishment]\n"\
159 "descriptionbad desc\n")
160- self.assertRaises(ConfigParser.ParsingError, api.Accomplishments,(None))
161+ self.assertRaises(ConfigParser.ParsingError, api.Accomplishments, None,
162+ None, True)
163 os.remove(os.path.join(self.accomp_dir, "bad.accomplishment"))
164
165 self.util_write_file(self.accomp_dir, "bad.accomplishment",
166 "[accomplishment]\n"\
167 "titlewhatever\n"\
168 "description=bad desc\n")
169- self.assertRaises(ConfigParser.ParsingError, api.Accomplishments,(None))
170+ self.assertRaises(ConfigParser.ParsingError, api.Accomplishments, None,
171+ None, True)
172 os.remove(os.path.join(self.accomp_dir, "bad.accomplishment"))
173
174 # also tests get_config_value()
175 def test_write_config_file_item(self):
176- a = api.Accomplishments(None)
177+ a = api.Accomplishments(None, None, True)
178 a.write_config_file_item('config', 'has_verif', False)
179 self.assertEquals(a.get_config_value('config', 'has_verif'), False)
180 self.assertEqual(a.has_verif, False)
181@@ -431,7 +433,7 @@
182 self.util_copy_accomp(self.accomp_dir, "first")
183 self.util_copy_accomp(self.accomp_dir, "second")
184 self.util_copy_accomp(self.accomp_dir, "third")
185- a = api.Accomplishments(None)
186+ a = api.Accomplishments(None, None, True)
187
188 # list_collections
189 collections = a.list_collections()
190@@ -478,7 +480,7 @@
191 self.util_copy_accomp(self.accomp_dir, "first")
192 self.util_copy_accomp(self.accomp_dir, "second")
193 self.util_copy_accomp(self.accomp_dir, "third")
194- a = api.Accomplishments(None)
195+ a = api.Accomplishments(None, None, True)
196
197 self.assertTrue(a.get_trophy_path("%s/first" %
198 self.ACCOMP_SET).endswith("first.trophy"))
199@@ -488,7 +490,7 @@
200 self.ACCOMP_SET).endswith("third.trophy"))
201
202 def test_write_extra_information_file(self):
203- a = api.Accomplishments(None)
204+ a = api.Accomplishments(None, None, True)
205
206 # write extra information will make the directory for us if needed,
207 # so lets remove it (if present and force it to)
208@@ -509,7 +511,7 @@
209 # get_all_extra_information()
210 # get_all_extra_information_required()
211 def test_get_extra_information_all_funcs(self):
212- a = api.Accomplishments(None)
213+ a = api.Accomplishments(None, None, True)
214 self.util_copy_extrainfo(self.extrainfo_dir, "info")
215 self.util_copy_extrainfo(self.extrainfo_dir, "info2")
216 self.util_copy_accomp(self.accomp_dir, "first")
217
218=== modified file 'debian/control'
219--- debian/control 2012-07-14 02:19:40 +0000
220+++ debian/control 2012-07-16 19:00:24 +0000
221@@ -1,10 +1,18 @@
222 Source: accomplishments-daemon
223 Section: python
224 Priority: extra
225-Build-Depends: cdbs (>= 0.4.43),
226- debhelper (>= 6),
227+Build-Depends: debhelper (>= 6),
228 python (>= 2.6.6-3~),
229 python-nose,
230+ python-twisted-core,
231+ python-xdg,
232+ python-dbus,
233+ python-imaging,
234+ python-gobject-2,
235+ python-gpgme,
236+ ubuntuone-couch,
237+ python-ubuntuone-client,
238+ python-ubuntu-sso-client,
239 python-distutils-extra (>= 2.10)
240 Maintainer: Jono Bacon <jono@ubuntu.com>
241 Standards-Version: 3.9.3
242@@ -19,11 +27,13 @@
243 gir1.2-gtk-3.0,
244 python-dbus,
245 python-ubuntuone-client,
246+ python-ubuntu-sso-client,
247 ubuntuone-couch,
248 python-twisted-core,
249 python-notify,
250 python-gobject-2,
251 ubuntuone-client,
252+ python-imaging,
253 python-gpgme
254 Description: Background daemon for running the Ubuntu Accomplishments system.
255 This is the background daemon process that is required to run the Ubuntu
256
257=== modified file 'debian/rules'
258--- debian/rules 2012-07-14 02:19:40 +0000
259+++ debian/rules 2012-07-16 19:00:24 +0000
260@@ -8,6 +8,10 @@
261
262 override_dh_auto_test:
263 ifeq ($(filter nocheck,$(DEB_BUILD_OPTIONS)),)
264+ mkdir -p debian/tmp/locale/
265+ localedef -f UTF-8 -i en_US ./debian/tmp/locale/en_US.UTF-8/
266+ export LOCPATH=$(CURDIR)/debian/tmp/locale/ && \
267+ export LC_ALL=en_US.UTF-8 && \
268 set -ex; for python in $(shell pyversions -r) ; do \
269 $$python /usr/bin/nosetests -v ; \
270 done

Subscribers

People subscribed via source and target branches