Merge lp:~verterok/ubuntuone-client/fix-557160-stable into lp:ubuntuone-client/stable-1-2

Proposed by Guillermo Gonzalez
Status: Merged
Approved by: Natalia Bidart
Approved revision: 508
Merged at revision: 509
Proposed branch: lp:~verterok/ubuntuone-client/fix-557160-stable
Merge into: lp:ubuntuone-client/stable-1-2
Diff against target: 296 lines (+76/-26)
9 files modified
tests/syncdaemon/test_action_queue.py (+3/-5)
tests/syncdaemon/test_dbus.py (+19/-1)
tests/syncdaemon/test_eq_inotify.py (+2/-1)
tests/syncdaemon/test_localrescan.py (+1/-1)
tests/syncdaemon/test_tools.py (+2/-2)
tests/syncdaemon/test_u1sdtool.py (+2/-2)
tests/syncdaemon/test_vm.py (+39/-11)
ubuntuone/syncdaemon/dbus_interface.py (+2/-0)
ubuntuone/syncdaemon/volume_manager.py (+6/-3)
To merge this branch: bzr merge lp:~verterok/ubuntuone-client/fix-557160-stable
Reviewer Review Type Date Requested Status
Joshua Hoover (community) ran branch and verified fix Approve
John O'Brien (community) Approve
Review via email: mp+25481@code.launchpad.net

Commit message

Fix Bug #557160 so UDFs with non-ASCII names (valid UTF-8) can be created using the DBus Interface.

Description of the change

This branch fix Bug #557160 so UDFs with non-ASCII names (valid UTF-8) can be created using the DBus Interface.

To post a comment you must log in.
Revision history for this message
John O'Brien (jdobrien) wrote :

Works great!

review: Approve
Revision history for this message
Joshua Hoover (joshuahoover) wrote :

Used the branch (with ubuntuone-storage-protocol/stable-1-2) to run the test case in bug #557160 and everything worked as expected.

review: Approve (ran branch and verified fix)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/syncdaemon/test_action_queue.py'
2--- tests/syncdaemon/test_action_queue.py 2010-04-12 17:58:20 +0000
3+++ tests/syncdaemon/test_action_queue.py 2010-05-17 22:28:35 +0000
4@@ -1033,8 +1033,7 @@
5 def test_SV_HASH_NEW_is_pushed_for_subscrined_volume(self):
6 """SV_HASH_NEW is filtered when the volume is unsubscribed."""
7 udf_id = 'udf_id'
8- udf_volume = volumes.UDFVolume(udf_id, 'udf_node',
9- u'~/ñoño'.encode("utf8"))
10+ udf_volume = volumes.UDFVolume(udf_id, 'udf_node', u'~/ñoño')
11 path = self.vm._build_udf_path(udf_volume.suggested_path)
12 udf = UDF.from_udf_volume(udf_volume, path)
13 yield self.vm.add_udf(udf)
14@@ -1048,12 +1047,11 @@
15 self.action_queue.event_queue.events)
16
17 @defer.inlineCallbacks
18- def test_SV_HASH_NEW_is_filtered_for_unsubscrined_volume(self):
19+ def test_SV_HASH_NEW_is_filtered_for_unsubscribed_volume(self):
20 """SV_HASH_NEW is filtered when the volume is unsubscribed."""
21 # build a VM and add it an UDF with subscribed to False
22 udf_id = 'udf_id'
23- udf_volume = volumes.UDFVolume(udf_id, 'udf_node',
24- u'~/ñoño'.encode("utf8"))
25+ udf_volume = volumes.UDFVolume(udf_id, 'udf_node', u'~/ñoño')
26 path = self.vm._build_udf_path(udf_volume.suggested_path)
27 udf = UDF.from_udf_volume(udf_volume, path)
28 yield self.vm.add_udf(udf)
29
30=== modified file 'tests/syncdaemon/test_dbus.py'
31--- tests/syncdaemon/test_dbus.py 2010-04-09 18:21:13 +0000
32+++ tests/syncdaemon/test_dbus.py 2010-05-17 22:28:35 +0000
33@@ -799,7 +799,7 @@
34 expected = []
35 udf_id = str(uuid.uuid4())
36 udf_path = self.main.vm._build_udf_path('~/foo/bar')
37- udf = UDF(str(udf_id), str('udf_node_id'), '~/foo/bar', udf_path, True)
38+ udf = UDF(str(udf_id), str('udf_node_id'), u'~/foo/bar', udf_path, True)
39 self.main.vm.udfs[udf_id] = udf
40 for i in xrange(5):
41 if i % 2:
42@@ -1821,6 +1821,9 @@
43 def _create_udf(self, id, node_id, suggested_path, subscribed=True):
44 """Create an UDF and returns it and the volume"""
45 path = self.main.vm._build_udf_path(suggested_path)
46+ # make sure suggested_path is unicode
47+ if isinstance(suggested_path, str):
48+ suggested_path = suggested_path.decode('utf-8')
49 udf = UDF(str(id), str(node_id), suggested_path, path, subscribed)
50 return udf
51
52@@ -1837,6 +1840,21 @@
53 self.assertEquals(udf_dict['node_id'], udf.node_id)
54 self.assertFalse(udf_dict['subscribed'])
55
56+ def test_get_udf_dict_bad_encoding(self):
57+ """Test for Folders._get_udf_dict."""
58+ suggested_path = u'~/Música'
59+ udf = self._create_udf(uuid.uuid4(), 'node_id', suggested_path,
60+ subscribed=False)
61+ udf.suggested_path = udf.suggested_path.encode('utf-8')
62+ udf_dict = self.dbus_iface.folders._get_udf_dict(udf)
63+ # check the path it's unicode
64+ self.assertEquals(udf_dict['path'], udf.path.decode('utf-8'))
65+ self.assertEquals(udf_dict['volume_id'], udf.id)
66+ self.assertEquals(repr(udf_dict['suggested_path']),
67+ repr(udf.suggested_path.decode('utf-8')))
68+ self.assertEquals(udf_dict['node_id'], udf.node_id)
69+ self.assertFalse(udf_dict['subscribed'])
70+
71 @defer.inlineCallbacks
72 def test_get_folders(self):
73 """Test for Folders.get_folders."""
74
75=== modified file 'tests/syncdaemon/test_eq_inotify.py'
76--- tests/syncdaemon/test_eq_inotify.py 2010-03-26 15:58:49 +0000
77+++ tests/syncdaemon/test_eq_inotify.py 2010-05-17 22:28:35 +0000
78@@ -49,7 +49,8 @@
79 def _create_udf(self, path):
80 """Create an UDF and returns it and the volume"""
81 os.makedirs(path)
82- udf = volume_manager.UDF("vol_id", "node_id", path, path, True)
83+ udf = volume_manager.UDF("vol_id", "node_id", path.decode('utf-8'),
84+ path, True)
85 self.vm.add_udf(udf)
86
87 def test_add_general_watch(self):
88
89=== modified file 'tests/syncdaemon/test_localrescan.py'
90--- tests/syncdaemon/test_localrescan.py 2010-04-16 16:23:58 +0000
91+++ tests/syncdaemon/test_localrescan.py 2010-05-17 22:28:35 +0000
92@@ -102,7 +102,7 @@
93
94 def create_udf(self, udf_id, node_id, suggested_path, path, subscribed):
95 """Create an UDF and add it to the volume manager."""
96- volume = volumes.UDFVolume(udf_id, node_id, suggested_path)
97+ volume = volumes.UDFVolume(udf_id, node_id, suggested_path.decode('utf-8'))
98 udf = volume_manager.UDF.from_udf_volume(volume, path)
99 udf.subscribed = subscribed
100 self.fsm.vm.add_udf(udf)
101
102=== modified file 'tests/syncdaemon/test_tools.py'
103--- tests/syncdaemon/test_tools.py 2010-03-09 21:38:33 +0000
104+++ tests/syncdaemon/test_tools.py 2010-05-17 22:28:35 +0000
105@@ -380,7 +380,7 @@
106 @defer.inlineCallbacks
107 def test_delete_folder(self):
108 """Test for Folders.delete."""
109- path = os.path.join(self.home_dir, 'ñoño')
110+ path = os.path.join(self.home_dir, u'ñoño').encode('utf-8')
111 # patch AQ.delete_volume
112 def delete_volume(volume_id):
113 """Fake delete_volume"""
114@@ -388,7 +388,7 @@
115 self.main.action_q.delete_volume = delete_volume
116
117 # create sample folder
118- suggested_path = os.path.join("~", 'ñoño')
119+ suggested_path = os.path.join("~", u'ñoño').decode('utf-8')
120 udf = volume_manager.UDF("folder_id", "node_id", suggested_path, path,
121 subscribed=True)
122 yield self.main.vm.add_udf(udf)
123
124=== modified file 'tests/syncdaemon/test_u1sdtool.py'
125--- tests/syncdaemon/test_u1sdtool.py 2010-03-30 14:25:27 +0000
126+++ tests/syncdaemon/test_u1sdtool.py 2010-05-17 22:28:35 +0000
127@@ -301,8 +301,8 @@
128 def test_show_folders(self):
129 """test the output of --list-folders """
130 out = StringIO()
131- path = 'ñoño'
132- suggested_path = os.path.join("~", 'ñoño')
133+ path = u'ñoño'.encode('utf-8')
134+ suggested_path = os.path.join("~", u'ñoño')
135
136 udf = UDF("folder_id", "node_id", suggested_path, path,
137 subscribed=True)
138
139=== modified file 'tests/syncdaemon/test_vm.py'
140--- tests/syncdaemon/test_vm.py 2010-04-07 13:56:56 +0000
141+++ tests/syncdaemon/test_vm.py 2010-05-17 22:28:35 +0000
142@@ -635,6 +635,9 @@
143 """Create an UDF and returns it and the volume"""
144 with environ('HOME', self.home_dir):
145 path = self.vm._build_udf_path(suggested_path)
146+ # make sure suggested_path is unicode
147+ if isinstance(suggested_path, str):
148+ suggested_path = suggested_path.decode('utf-8')
149 volume = volumes.UDFVolume(id, node_id, suggested_path)
150 udf = UDF.from_udf_volume(volume, path)
151 udf.subscribed = subscribed
152@@ -642,10 +645,11 @@
153
154 def test_build_udf_path(self):
155 """Test for VolumeManager._build_udf_path."""
156- suggested_path = "suggested_path"
157+ suggested_path = u"suggested_path"
158 with environ('HOME', self.home_dir):
159- udf_path = self.vm._build_udf_path("~/" + suggested_path)
160- self.assertEquals(os.path.join(self.home_dir, suggested_path),
161+ udf_path = self.vm._build_udf_path(u"~/" + suggested_path)
162+ self.assertEquals(os.path.join(self.home_dir,
163+ suggested_path.encode('utf-8')),
164 udf_path)
165
166 def test_udf_ancestors(self):
167@@ -810,7 +814,7 @@
168 'to_me', 'fake_share', 'username',
169 'visible_username', True, 'View')
170 udf_id = uuid.uuid4()
171- udf_volume = volumes.UDFVolume(udf_id, 'udf_uuid', '~/UDF')
172+ udf_volume = volumes.UDFVolume(udf_id, 'udf_uuid', u'~/UDF')
173 root_volume = volumes.RootVolume(uuid.uuid4())
174 response = [share_volume, udf_volume, root_volume]
175 d = defer.Deferred()
176@@ -877,8 +881,7 @@
177 'username', 'visible_username',
178 True, 'View')
179 udf_id = uuid.uuid4()
180- udf_volume = volumes.UDFVolume(udf_id, 'udf_uuid',
181- u'~/ñoño'.encode("utf8") )
182+ udf_volume = volumes.UDFVolume(udf_id, 'udf_uuid', u'~/ñoño')
183 # initialize the the root
184 self.vm.handle_SYS_ROOT_RECEIVED('root_uuid')
185 response = [share_volume, udf_volume]
186@@ -956,7 +959,9 @@
187 self.assertEquals(udf.path, path)
188 self.assertEquals(udf.volume_id, str(udf_id))
189 self.assertEquals(udf.node_id, str(node_id))
190- self.assertEquals(udf.suggested_path, '~/MyUDF')
191+ self.assertEquals(udf.suggested_path, u'~/MyUDF')
192+ self.assertTrue(isinstance(udf.suggested_path, unicode),
193+ 'suggested_path should be unicode')
194 self.assertIn(udf.volume_id, self.vm.udfs)
195
196 self._listen_for('VM_UDF_CREATED', d.callback)
197@@ -965,6 +970,28 @@
198 d.addCallback(check)
199 return d
200
201+ def test_create_udf_unicode(self):
202+ """Test VolumeManager.create_udf.
203+
204+ Check that VM calls AQ.create_udf with unicode values.
205+ """
206+ d = defer.Deferred()
207+ path = os.path.join(self.home_dir, u"ñoño", u"mirá que lindo mi udf").encode('utf-8')
208+ # patch AQ.create_udf
209+ def create_udf(path, name, marker):
210+ """Fake create_udf"""
211+ d.callback((path, name))
212+ self.main.action_q.create_udf = create_udf
213+ def check(info):
214+ """Check the values passed to AQ.create_udf"""
215+ path, name = info
216+ self.assertTrue(isinstance(name, unicode), 'name should be unicode but is: %s' % type(name))
217+ self.assertTrue(isinstance(path, unicode), 'path should be unicode but is: %s' % type(name))
218+ with environ('HOME', self.home_dir):
219+ self.vm.create_udf(path)
220+ d.addCallback(check)
221+ return d
222+
223 @defer.inlineCallbacks
224 def test_delete_volume(self):
225 """
226@@ -1356,8 +1383,7 @@
227 # start the test
228 d = defer.Deferred()
229 udf_id = uuid.uuid4()
230- udf_volume = volumes.UDFVolume(udf_id, 'udf_uuid',
231- u'~/ñoño'.encode("utf8") )
232+ udf_volume = volumes.UDFVolume(udf_id, 'udf_uuid', u'~/ñoño')
233 share_id = uuid.uuid4()
234 share_volume = volumes.ShareVolume(share_id, 'fake_share_uuid',
235 'to_me', u'ñoño'.encode("utf8"),
236@@ -1606,7 +1632,7 @@
237 'to_me', 'fake_share', 'username',
238 'visible_username', True, 'View')
239 udf_id = uuid.uuid4()
240- udf_volume = volumes.UDFVolume(udf_id, 'udf_uuid', '~/UDF')
241+ udf_volume = volumes.UDFVolume(udf_id, 'udf_uuid', u'~/UDF')
242 root_volume = volumes.RootVolume(uuid.uuid4())
243 response = [share_volume, udf_volume, root_volume]
244 d = defer.Deferred()
245@@ -2419,7 +2445,7 @@
246 for idx, name in enumerate(['dir'] * 5):
247 udf_id = str(uuid.uuid4())
248 udf_name = name + '_' + str(idx)
249- udf = _UDF(udf_id, str(uuid.uuid4()), '~/' + udf_name,
250+ udf = _UDF(udf_id, str(uuid.uuid4()), u'~/' + udf_name.decode('utf-8'),
251 os.path.join(self.home_dir, udf_name))
252 if idx % 2:
253 udf.subscribed = True
254@@ -2470,6 +2496,8 @@
255 self.assertEquals(udf.path, old_udf.path)
256 self.assertEquals(udf.node_id, old_udf.node_id)
257 self.assertEquals(udf.suggested_path, old_udf.suggested_path)
258+ self.assertEquals(type(udf.suggested_path),
259+ type(old_udf.suggested_path))
260 self.assertEquals(udf.subscribed, old_udf.subscribed)
261
262 def test_upgrade_5_partial_upgrade(self):
263
264=== modified file 'ubuntuone/syncdaemon/dbus_interface.py'
265--- ubuntuone/syncdaemon/dbus_interface.py 2010-04-09 18:21:13 +0000
266+++ ubuntuone/syncdaemon/dbus_interface.py 2010-05-17 22:28:35 +0000
267@@ -1246,6 +1246,8 @@
268 udf_dict[unicode(k)] = self.bool_str(v)
269 elif k == 'path':
270 udf_dict[unicode(k)] = v.decode('utf-8')
271+ elif k == 'suggested_path' and isinstance(v, str):
272+ udf_dict[unicode(k)] = v.decode('utf-8')
273 else:
274 udf_dict[unicode(k)] = unicode(v)
275 return udf_dict
276
277=== modified file 'ubuntuone/syncdaemon/volume_manager.py'
278--- ubuntuone/syncdaemon/volume_manager.py 2010-04-07 13:56:56 +0000
279+++ ubuntuone/syncdaemon/volume_manager.py 2010-05-17 22:28:35 +0000
280@@ -868,10 +868,13 @@
281 return
282 # the UDF it's in subscribed state by default
283 subscribe = config.get_user_config().get_udf_autosubscribe()
284- udf = UDF(None, None, os.path.join(udf_path, udf_name), path,
285- subscribed=subscribe)
286+ udf = UDF(None, None,
287+ # suggested_path is always unicode
288+ os.path.join(udf_path, udf_name).decode('utf-8'),
289+ path, subscribed=subscribe)
290 self.marker_udf_map[marker] = udf
291- self.m.action_q.create_udf(udf_path, udf_name, marker)
292+ self.m.action_q.create_udf(udf_path.decode('utf-8'),
293+ udf_name.decode('utf-8'), marker)
294 except Exception, e:
295 self.m.event_q.push('VM_UDF_CREATE_ERROR', path,
296 "UNKNOWN_ERROR: %s" % e)

Subscribers

People subscribed via source and target branches