Merge lp:~ralsina/ubuntuone-windows-installer/fix-tests into lp:ubuntuone-windows-installer

Proposed by Roberto Alsina
Status: Superseded
Proposed branch: lp:~ralsina/ubuntuone-windows-installer/fix-tests
Merge into: lp:ubuntuone-windows-installer
Diff against target: 278 lines (+66/-28)
8 files modified
ubuntuone_installer/gui/qt/gui.py (+0/-4)
ubuntuone_installer/gui/qt/local_folders.py (+10/-5)
ubuntuone_installer/gui/qt/main/windows.py (+1/-2)
ubuntuone_installer/gui/qt/tests/test_gui.py (+10/-9)
ubuntuone_installer/gui/qt/tests/test_local_folders.py (+40/-8)
ubuntuone_installer/gui/qt/utils/linux.py (+1/-0)
ubuntuone_installer/gui/qt/utils/tests/test_windows.py (+2/-0)
ubuntuone_installer/gui/qt/utils/windows.py (+2/-0)
To merge this branch: bzr merge lp:~ralsina/ubuntuone-windows-installer/fix-tests
Reviewer Review Type Date Requested Status
Ubuntu One hackers Pending
Review via email: mp+73246@code.launchpad.net

This proposal has been superseded by a proposal from 2011-08-29.

Commit message

Make the tests pass on Linux, also fixes a bunch of lint notices.

Description of the change

Make the tests pass on Linux, also fixes a bunch of lint notices.

To post a comment you must log in.
46. By Roberto Alsina

link another bug

47. By Roberto Alsina

re-enable pylint import errors after the problematic one

48. By Roberto Alsina

moved default_folders into utils

49. By Roberto Alsina

removed unused imports

50. By Roberto Alsina

lint fix

51. By Roberto Alsina

suggested fixes

52. By Roberto Alsina

suggested fixes

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone_installer/gui/qt/gui.py'
2--- ubuntuone_installer/gui/qt/gui.py 2011-08-29 12:41:02 +0000
3+++ ubuntuone_installer/gui/qt/gui.py 2011-08-29 15:34:35 +0000
4@@ -20,10 +20,6 @@
5
6 """The user interface for the Ubuntu One Installer."""
7
8-import os
9-import subprocess
10-import sys
11-
12 import gettext
13
14 from PyQt4 import QtGui, QtCore
15
16=== modified file 'ubuntuone_installer/gui/qt/local_folders.py'
17--- ubuntuone_installer/gui/qt/local_folders.py 2011-08-19 15:25:18 +0000
18+++ ubuntuone_installer/gui/qt/local_folders.py 2011-08-29 15:34:35 +0000
19@@ -191,10 +191,13 @@
20 music = buf.value
21 dll.SHGetSpecialFolderPathA(None, buf, 39, False)
22 pictures = buf.value
23- return [docs, music, pictures]
24 else:
25- result = ['To be implemented']
26- return result
27+ # FIXME: this should be taken from ~/.config/user-dirs.dirs
28+ # but pyxdg doesn't seem to provide any access to that data.
29+ docs = os.path.expanduser("~/Documents")
30+ music = os.path.expanduser("~/Music")
31+ pictures = os.path.expanduser("~/Pictures")
32+ return [docs, music, pictures]
33
34 @inlineCallbacks
35 def add_folder(self, path, validate=True, calculate=True, volume_id=None):
36@@ -292,8 +295,10 @@
37 @QtCore.pyqtSlot()
38 def on_add_folder_button_clicked(self):
39 """user clicked on the "Add Folder" button."""
40- folder = QtGui.QFileDialog.getExistingDirectory(parent=self)
41- folder = unicode(folder)
42+ folder = QtGui.QFileDialog.getExistingDirectory(
43+ parent=self,
44+ options=QtGui.QFileDialog.DontUseNativeDialog)
45+ folder = unicode(QtCore.QDir.toNativeSeparators(folder))
46 if folder == '':
47 return
48
49
50=== modified file 'ubuntuone_installer/gui/qt/main/windows.py'
51--- ubuntuone_installer/gui/qt/main/windows.py 2011-08-29 12:41:02 +0000
52+++ ubuntuone_installer/gui/qt/main/windows.py 2011-08-29 15:34:35 +0000
53@@ -86,12 +86,11 @@
54 # pylint: enable=W0612
55 import qtreactor.qt4reactor
56 qtreactor.qt4reactor.install()
57- from ubuntuone_installer.gui.qt import gui, utils
58+ from ubuntuone_installer.gui.qt import gui
59 from twisted.internet import reactor
60 # All this has to be imported here because it installs a reactor
61 from ubuntuone.platform.credentials import CredentialsManagementTool
62 from ubuntuone_installer.logger import setup_logging
63 logger = setup_logging('qt.gui')
64-
65 check_credentials(CredentialsManagementTool, gui, logger)
66 reactor.run()
67
68=== modified file 'ubuntuone_installer/gui/qt/tests/test_gui.py'
69--- ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-26 17:25:18 +0000
70+++ ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-29 15:34:35 +0000
71@@ -20,8 +20,9 @@
72 """Tests for the Qt UI."""
73
74 import os
75+import subprocess
76+import sys
77
78-from twisted.internet import defer
79 from PyQt4 import QtGui, QtCore
80 from ubuntuone.devtools.testcase import skipIfOS
81 from ubuntuone.platform.credentials import APP_NAME
82@@ -360,11 +361,11 @@
83 def test_start_control_panel_on_finishing(self):
84 """Calling done with result=1, the control panel should be called."""
85 gui.AreYouSure.result = 0
86- self.patch(gui.subprocess, "Popen", self._set_called)
87+ self.patch(subprocess, "Popen", self._set_called)
88 # If it's frozen this test fails because the path
89 # depends on the location of the exe
90- if hasattr(gui.sys, "frozen"):
91- delattr(gui.sys, "frozen")
92+ if hasattr(sys, "frozen"):
93+ delattr(sys, "frozen")
94 self.ui.done(result=1)
95 self.assertEqual(self._called,
96 ((['ubuntuone-control-panel-qt'],), {}))
97@@ -378,8 +379,8 @@
98 self.addCleanup(self.ui.hide)
99 gui.AreYouSure.result = 0
100 # I can't patch sys because frozen is not there by default
101- gui.sys.frozen = True
102- self.patch(gui.subprocess, "Popen", self._set_called)
103+ sys.frozen = True
104+ self.patch(subprocess, "Popen", self._set_called)
105 self.ui.done(result=1)
106 self.assertIn(os.sep, self._called[0][0][0])
107 self.assertIn('ubuntuone-control-panel-qt', self._called[0][0][0])
108@@ -387,14 +388,14 @@
109 def test_not_start_control_panel_on_cancel(self):
110 """Called done with result=0, control panel should NOT be called."""
111 gui.AreYouSure.result = 0
112- self.patch(gui.subprocess, "Popen", self._set_called)
113+ self.patch(subprocess, "Popen", self._set_called)
114 self.ui.done(result=0)
115 self.assertEqual(self._called, False)
116
117 def test_continue_cancels_cancel(self):
118 """Clicking 'Continue' cancels cancellation."""
119 gui.AreYouSure.result = 1
120- self.patch(gui.subprocess, "Popen", self._set_called)
121+ self.patch(subprocess, "Popen", self._set_called)
122 self.ui.show()
123 self.addCleanup(self.ui.hide)
124 self.ui.done(result=0)
125@@ -405,7 +406,7 @@
126 self.ui.show()
127 self.addCleanup(self.ui.hide)
128 self.patch(self.ui, 'currentId', lambda: self.ui.CONGRATULATIONS_PAGE)
129- self.patch(gui.subprocess, "Popen", self._set_called)
130+ self.patch(subprocess, "Popen", self._set_called)
131 self.ui.done(result=0)
132 self.assertEqual(self._called, False)
133 self.assertEqual(FakeAreYouSure.shown, False)
134
135=== modified file 'ubuntuone_installer/gui/qt/tests/test_local_folders.py'
136--- ubuntuone_installer/gui/qt/tests/test_local_folders.py 2011-08-19 15:25:18 +0000
137+++ ubuntuone_installer/gui/qt/tests/test_local_folders.py 2011-08-29 15:34:35 +0000
138@@ -23,8 +23,9 @@
139 import shutil
140 import tempfile
141
142+from PyQt4 import QtGui, QtCore
143 from twisted.internet import defer
144-from PyQt4 import QtGui, QtCore
145+from ubuntuone.devtools.testcase import skipIfOS
146
147 from ubuntuone_installer.gui.qt import local_folders
148 from ubuntuone_installer.gui.qt.tests import BaseTestCase, TestCase
149@@ -35,10 +36,12 @@
150
151 """A fake QFileDialog class."""
152
153+ DontUseNativeDialog = 4
154+
155 # pylint: disable=C0103
156 def getExistingDirectory(self, *args, **kwargs):
157 """Fake existing folder name."""
158- return u"whatever"
159+ return QtCore.QString("c:\\whatever")
160
161
162 class FakeMessageBox(object):
163@@ -449,7 +452,7 @@
164 self.patch(self.ui, "add_folder", self._set_called)
165 self.ui.ui.add_folder_button.click()
166 self.assertEqual(self._called,
167- ((u'whatever',), {'validate': False, 'volume_id': False}))
168+ ((u'c:\\whatever',), {'validate': False, 'volume_id': False}))
169
170 def test_add_folder_clicked_invalid(self):
171 """Test behaviour when adding an invalid folder via the button."""
172@@ -462,7 +465,7 @@
173 self.assertEqual(self._called, False)
174 user_home = os.path.expanduser('~')
175 text = local_folders.FOLDER_INVALID_PATH % {
176- 'folder_path': "whatever",
177+ 'folder_path': u"c:\\whatever",
178 'home_folder': user_home,
179 }
180 # pylint: disable=W0212
181@@ -477,9 +480,10 @@
182 show_counter = self.ui.wizard().overlay.show_counter
183 hide_counter = self.ui.wizard().overlay.hide_counter
184 self.ui.changed_page(self.ui.wizard().SYNC_NOW_OR_LATER_PAGE)
185- self.assertEqual(self.ui.cp_backend.volume_setings_changes,
186- [('asdfgh', {'subscribed': True}),
187- ('qwerty', {'subscribed': False})])
188+ changes = sorted(self.ui.cp_backend.volume_setings_changes)
189+ self.assertEqual(changes,
190+ sorted([('asdfgh', {'subscribed': True}),
191+ ('qwerty', {'subscribed': False})]))
192 self.assertEqual(self.ui.wizard().overlay.show_counter,
193 show_counter + 1)
194 self.assertEqual(self.ui.wizard().overlay.hide_counter,
195@@ -522,7 +526,8 @@
196 self.ui.changed_page(-1)
197 self.assertFalse(self.ui.timer.isActive())
198
199- def test_special_folders(self):
200+ @skipIfOS('linux2', 'Windows specific test.')
201+ def test_special_folders_windows(self):
202 """Test that default_folders does the right thing."""
203 folders = self.ui.default_folders()
204 self.assertEqual(len(folders), 3)
205@@ -540,6 +545,19 @@
206 expected = [docs, music, pictures]
207 self.assertEqual(sorted(folders), sorted(expected))
208
209+ @skipIfOS('win32', 'Linux specific test.')
210+ def test_special_folders_linux(self):
211+ """Test that default_folders does the right thing."""
212+ folders = self.ui.default_folders()
213+ self.assertEqual(len(folders), 3)
214+ self.assertEqual(folders, [os.path.abspath(f) for f in folders])
215+ # pylint: disable=W0404
216+ docs = os.path.expanduser("~/Documents")
217+ music = os.path.expanduser("~/Music")
218+ pictures = os.path.expanduser("~/Pictures")
219+ expected = [docs, music, pictures]
220+ self.assertEqual(sorted(folders), sorted(expected))
221+
222 def test_on_folder_list_item_changed_col_0(self):
223 """Test that it calls the right thing."""
224 self.patch(self.ui, 'update_sizes', self._set_called)
225@@ -583,3 +601,17 @@
226 self.assertFalse(self.ui.queue.empty())
227 self.ui.update_sizes()
228 self.assertTrue(self.ui.queue.empty())
229+
230+ @defer.inlineCallbacks
231+ def test_not_native(self):
232+ """Test that we are *not* using the native file dialog."""
233+ self.patch(local_folders.QtGui.QFileDialog,
234+ "getExistingDirectory", self._set_called)
235+ try:
236+ yield self.ui.on_add_folder_button_clicked()
237+ except TypeError:
238+ pass # Expected exception
239+ self.assertEqual(self._called, ((), {
240+ 'options': local_folders.QtGui.QFileDialog.DontUseNativeDialog,
241+ 'parent': self.ui,
242+ }))
243
244=== modified file 'ubuntuone_installer/gui/qt/utils/linux.py'
245--- ubuntuone_installer/gui/qt/utils/linux.py 2011-08-29 12:41:02 +0000
246+++ ubuntuone_installer/gui/qt/utils/linux.py 2011-08-29 15:34:35 +0000
247@@ -20,6 +20,7 @@
248
249 import subprocess
250
251+
252 def uninstall_application():
253 """Uninstall Ubuntu One."""
254 pass
255
256=== modified file 'ubuntuone_installer/gui/qt/utils/tests/test_windows.py'
257--- ubuntuone_installer/gui/qt/utils/tests/test_windows.py 2011-08-29 12:41:02 +0000
258+++ ubuntuone_installer/gui/qt/utils/tests/test_windows.py 2011-08-29 15:34:35 +0000
259@@ -21,6 +21,8 @@
260 import sys
261 import os
262
263+# Avoid pylint error on Linux
264+# pylint: disable=F0401
265 import win32api
266
267 from ubuntuone_installer.gui.qt import utils
268
269=== modified file 'ubuntuone_installer/gui/qt/utils/windows.py'
270--- ubuntuone_installer/gui/qt/utils/windows.py 2011-08-29 12:41:02 +0000
271+++ ubuntuone_installer/gui/qt/utils/windows.py 2011-08-29 15:34:35 +0000
272@@ -23,6 +23,8 @@
273 import subprocess
274 import sys
275
276+# Avoid pylint error on Linux
277+# pylint: disable=F0401
278 import win32api
279
280

Subscribers

People subscribed via source and target branches