Merge lp:~diegosarmentero/ubuntuone-windows-installer/close-on-license into lp:ubuntuone-windows-installer

Proposed by Diego Sarmentero
Status: Merged
Merged at revision: 45
Proposed branch: lp:~diegosarmentero/ubuntuone-windows-installer/close-on-license
Merge into: lp:ubuntuone-windows-installer
Diff against target: 115 lines (+32/-22)
3 files modified
ubuntuone_installer/gui/qt/tests/__init__.py (+3/-17)
ubuntuone_installer/gui/qt/utils/tests/test_windows.py (+25/-2)
ubuntuone_installer/gui/qt/utils/windows.py (+4/-3)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntuone-windows-installer/close-on-license
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+73292@code.launchpad.net

Commit message

Allow the installer to be closed if the uninstaller couldn't be executed.

Description of the change

Allow the installer to be closed if the uninstaller couldn't be executed.

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) wrote :

+1

review: Approve
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

* I understand we can't patch sys to set frozen to it, but we should add a cleanup call to restore the absence of this attribute. So, this code:

        sys.frozen = True

should be followed by something like:

        self.addCleanup(del, sys.frozen)

* Same for this code, we need to restore the env like it was before the test run:

        if hasattr(sys, "frozen"):
            delattr(sys, "frozen")

should migrate to something like:

        frozen = getattr(sys, "frozen", None)
        if frozen is not None:
            delattr(sys, "frozen")
            self.addCleanup(setattr, sys, 'frozen', frozen)

* Unless I'm missing something, there is no need to define the FakeCaller, isn't? The test case base class inherits from a testcase that has the _set_called method defined, so you can replace:

        self.patch(win32api, "ShellExecute", fake_caller.call)
        self.assertFalse(FakeCaller.was_called)

with:

        self.patch(win32api, "ShellExecute", self._set_called)
        self.assertFalse(self._called)

Also, this code:

        self.patch(os.path, "exists", fake_caller.exists)

can morph into (is easier to read, no need to scroll up to see what does fake_caller is/does):

        self.patch(os.path, "exists", lambda path: True)

Thanks!

review: Needs Fixing
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

There seems to be a conflict now that ralsina's fix-tests branch landed.

review: Needs Fixing
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

* This does not work:

self.addCleanup(setattr(sys, 'frozen', frozen))

addCleanup receives a function, so it should be:

self.addCleanup(setattr, sys, 'frozen', frozen)

* This self.addCleanup(lambda: delattr(sys, "frozen")) can be improved to self.addCleanup(delattr, sys, "frozen").

review: Needs Fixing
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Why you're asserting this?

self.assertFalse(hasattr(self, '_called'))

I would expect the test to assert self.assertFalse(self._called), I can't see how the _called attr disappears.

review: Needs Fixing
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

> Why you're asserting this?
>
> self.assertFalse(hasattr(self, '_called'))
>
> I would expect the test to assert self.assertFalse(self._called), I can't see
> how the _called attr disappears.

I'm testing that this function is not being called really, and BaseTestCase create self._called when that function is executed, so i'm testing that the attribute doesn't exists.

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Seems like some class in the inheriting chain is not calling setUp, so I would recommend fixing that instead of the proposed hasattr call:

     25 class TestCase(BaseTestCase):
     26 """Basics for testing."""
     27
     28 assertIs = BaseTestCase.assertIdentical
     29
     30 def setUp(self):
     31 self._called = False

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Looks good! Please remove the unneeded call to setUp.

review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (4.5 KiB)

The attempt to merge lp:~diegosarmentero/ubuntuone-windows-installer/close-on-license into lp:ubuntuone-windows-installer failed. Below is the output from the failed tests.

running build
Compiled data/qt/local_folders.ui into ubuntuone_installer/gui/qt/ui/local_folders_ui.py
Compiled data/qt/preferences.ui into ubuntuone_installer/gui/qt/ui/preferences_ui.py
Compiled data/qt/congratulations.ui into ubuntuone_installer/gui/qt/ui/congratulations_ui.py
compiled data/qt/images.qrc into ubuntuone_installer/gui/qt/ui/images_rc.py
Compiled data/qt/folders.ui into ubuntuone_installer/gui/qt/ui/folders_ui.py
Compiled data/qt/sync_now_or_later.ui into ubuntuone_installer/gui/qt/ui/sync_now_or_later_ui.py
Compiled data/qt/license.ui into ubuntuone_installer/gui/qt/ui/license_ui.py
Compiled data/qt/choose_sign_in.ui into ubuntuone_installer/gui/qt/ui/choose_sign_in_ui.py
Compiled data/qt/side_widget.ui into ubuntuone_installer/gui/qt/ui/side_widget_ui.py
Compiled data/qt/sign_in.ui into ubuntuone_installer/gui/qt/ui/sign_in_ui.py
Compiled data/qt/setup_account.ui into ubuntuone_installer/gui/qt/ui/setup_account_ui.py
Compiled data/qt/are_you_sure.ui into ubuntuone_installer/gui/qt/ui/are_you_sure_ui.py
running build_py
creating build
creating build/lib.linux-i686-2.7
creating build/lib.linux-i686-2.7/ubuntuone_installer
copying ubuntuone_installer/__init__.py -> build/lib.linux-i686-2.7/ubuntuone_installer
copying ubuntuone_installer/logger.py -> build/lib.linux-i686-2.7/ubuntuone_installer
creating build/lib.linux-i686-2.7/ubuntuone_installer/gui
copying ubuntuone_installer/gui/__init__.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui
creating build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/__init__.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/enhanced_check_box.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/folders.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/forgotten.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/gui.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/side_widget.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/local_folders.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/setup_account.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/preferences.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/currentuser.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/sync_now_or_later.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/are_you_sure.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
running build_scripts
creating build/scripts-2.7
copying and adjusting bin/ubuntuone-installer-qt -> build/scripts-2.7
changing mode of build/scripts-2.7/ubuntuone-installer-qt from 644 to 755
running build_i18n
intltoo...

Read more...

Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (4.7 KiB)

The attempt to merge lp:~diegosarmentero/ubuntuone-windows-installer/close-on-license into lp:ubuntuone-windows-installer failed. Below is the output from the failed tests.

running build
Compiled data/qt/local_folders.ui into ubuntuone_installer/gui/qt/ui/local_folders_ui.py
Compiled data/qt/preferences.ui into ubuntuone_installer/gui/qt/ui/preferences_ui.py
Compiled data/qt/congratulations.ui into ubuntuone_installer/gui/qt/ui/congratulations_ui.py
compiled data/qt/images.qrc into ubuntuone_installer/gui/qt/ui/images_rc.py
Compiled data/qt/folders.ui into ubuntuone_installer/gui/qt/ui/folders_ui.py
Compiled data/qt/sync_now_or_later.ui into ubuntuone_installer/gui/qt/ui/sync_now_or_later_ui.py
Compiled data/qt/license.ui into ubuntuone_installer/gui/qt/ui/license_ui.py
Compiled data/qt/choose_sign_in.ui into ubuntuone_installer/gui/qt/ui/choose_sign_in_ui.py
Compiled data/qt/side_widget.ui into ubuntuone_installer/gui/qt/ui/side_widget_ui.py
Compiled data/qt/sign_in.ui into ubuntuone_installer/gui/qt/ui/sign_in_ui.py
Compiled data/qt/setup_account.ui into ubuntuone_installer/gui/qt/ui/setup_account_ui.py
Compiled data/qt/are_you_sure.ui into ubuntuone_installer/gui/qt/ui/are_you_sure_ui.py
running build_py
creating build
creating build/lib.linux-i686-2.7
creating build/lib.linux-i686-2.7/ubuntuone_installer
copying ubuntuone_installer/__init__.py -> build/lib.linux-i686-2.7/ubuntuone_installer
copying ubuntuone_installer/logger.py -> build/lib.linux-i686-2.7/ubuntuone_installer
creating build/lib.linux-i686-2.7/ubuntuone_installer/gui
copying ubuntuone_installer/gui/__init__.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui
creating build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/__init__.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/enhanced_check_box.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/folders.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/forgotten.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/gui.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/side_widget.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/local_folders.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/setup_account.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/preferences.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/currentuser.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/sync_now_or_later.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/are_you_sure.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
running build_scripts
creating build/scripts-2.7
copying and adjusting bin/ubuntuone-installer-qt -> build/scripts-2.7
changing mode of build/scripts-2.7/ubuntuone-installer-qt from 644 to 755
running build_i18n
intltoo...

Read more...

Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (4.5 KiB)

The attempt to merge lp:~diegosarmentero/ubuntuone-windows-installer/close-on-license into lp:ubuntuone-windows-installer failed. Below is the output from the failed tests.

running build
Compiled data/qt/local_folders.ui into ubuntuone_installer/gui/qt/ui/local_folders_ui.py
Compiled data/qt/preferences.ui into ubuntuone_installer/gui/qt/ui/preferences_ui.py
Compiled data/qt/congratulations.ui into ubuntuone_installer/gui/qt/ui/congratulations_ui.py
compiled data/qt/images.qrc into ubuntuone_installer/gui/qt/ui/images_rc.py
Compiled data/qt/folders.ui into ubuntuone_installer/gui/qt/ui/folders_ui.py
Compiled data/qt/sync_now_or_later.ui into ubuntuone_installer/gui/qt/ui/sync_now_or_later_ui.py
Compiled data/qt/license.ui into ubuntuone_installer/gui/qt/ui/license_ui.py
Compiled data/qt/choose_sign_in.ui into ubuntuone_installer/gui/qt/ui/choose_sign_in_ui.py
Compiled data/qt/side_widget.ui into ubuntuone_installer/gui/qt/ui/side_widget_ui.py
Compiled data/qt/sign_in.ui into ubuntuone_installer/gui/qt/ui/sign_in_ui.py
Compiled data/qt/setup_account.ui into ubuntuone_installer/gui/qt/ui/setup_account_ui.py
Compiled data/qt/are_you_sure.ui into ubuntuone_installer/gui/qt/ui/are_you_sure_ui.py
running build_py
creating build
creating build/lib.linux-i686-2.7
creating build/lib.linux-i686-2.7/ubuntuone_installer
copying ubuntuone_installer/__init__.py -> build/lib.linux-i686-2.7/ubuntuone_installer
copying ubuntuone_installer/logger.py -> build/lib.linux-i686-2.7/ubuntuone_installer
creating build/lib.linux-i686-2.7/ubuntuone_installer/gui
copying ubuntuone_installer/gui/__init__.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui
creating build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/__init__.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/enhanced_check_box.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/folders.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/forgotten.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/gui.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/side_widget.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/local_folders.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/setup_account.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/preferences.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/currentuser.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/sync_now_or_later.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
copying ubuntuone_installer/gui/qt/are_you_sure.py -> build/lib.linux-i686-2.7/ubuntuone_installer/gui/qt
running build_scripts
creating build/scripts-2.7
copying and adjusting bin/ubuntuone-installer-qt -> build/scripts-2.7
changing mode of build/scripts-2.7/ubuntuone-installer-qt from 644 to 755
running build_i18n
intltoo...

Read more...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone_installer/gui/qt/tests/__init__.py'
2--- ubuntuone_installer/gui/qt/tests/__init__.py 2011-06-22 10:47:08 +0000
3+++ ubuntuone_installer/gui/qt/tests/__init__.py 2011-09-01 18:28:36 +0000
4@@ -28,21 +28,6 @@
5 NO_OP = lambda *args: None
6
7
8-def skip_if_abstract_class(test):
9- """Decorator to skip a test if is an abstract class."""
10-
11- def inner(instance):
12- """Skip a test if is an abstract class."""
13- abstract = instance.class_ui is None
14- result = None
15- if not abstract:
16- result = test(instance)
17-
18- return result
19-
20- return inner
21-
22-
23 class FakeUi(FakedObject):
24 """A fake Ui object."""
25
26@@ -55,13 +40,14 @@
27 class_ui = None
28 kwargs = {}
29
30- @skip_if_abstract_class
31 def setUp(self):
32 super(BaseTestCase, self).setUp()
33 # self.class_ui is not callable
34 # pylint: disable=E1102
35 # pylint: disable=C0103
36- self.ui = self.class_ui(**self.kwargs)
37+ self.ui = None
38+ if self.class_ui is not None:
39+ self.ui = self.class_ui(**self.kwargs)
40
41 if hasattr(self.ui, 'backend'):
42 # clean backend calls
43
44=== modified file 'ubuntuone_installer/gui/qt/utils/tests/test_windows.py'
45--- ubuntuone_installer/gui/qt/utils/tests/test_windows.py 2011-08-30 14:11:48 +0000
46+++ ubuntuone_installer/gui/qt/utils/tests/test_windows.py 2011-09-01 18:28:36 +0000
47@@ -31,17 +31,38 @@
48
49
50 class UninstallerTestCase(BaseTestCase):
51-
52 """Test the uninstaller."""
53
54+ def test_execute_uninstall_on_licence_cancel_file_not_exists(self):
55+ """Pressing Disagree button from license page the uninstall is exec."""
56+ # If it's frozen this test fails because the path
57+ # depends on the location of the exe
58+ frozen = getattr(sys, "frozen", None)
59+ if frozen is not None:
60+ delattr(sys, "frozen")
61+ self.addCleanup(setattr, sys, 'frozen', frozen)
62+ self.patch(win32api, "ShellExecute", self._set_called)
63+ self.assertFalse(self._called)
64+
65+ def test_execute_uninstall_on_licence_cancel_frozen_file_not_exists(self):
66+ """Pressing Disagree button from license page the uninstall is exec."""
67+ self.patch(win32api, "ShellExecute", self._set_called)
68+ sys.frozen = True
69+ self.addCleanup(delattr, sys, "frozen")
70+ utils.uninstall_application()
71+ self.assertFalse(self._called)
72+
73 def test_execute_uninstall_on_licence_cancel(self):
74 """Pressing Disagree button from license page the uninstall is exec."""
75 self.patch(win32api, "ShellExecute", self._set_called)
76+ self.patch(os.path, "exists", lambda path: True)
77 utils.uninstall_application()
78 # If it's frozen this test fails because the path
79 # depends on the location of the exe
80- if hasattr(sys, "frozen"):
81+ frozen = getattr(sys, "frozen", None)
82+ if frozen is not None:
83 delattr(sys, "frozen")
84+ self.addCleanup(setattr, sys, 'frozen', frozen)
85 exec_path = os.path.abspath(__file__)
86 folder_path_utils_dir = os.path.dirname(exec_path)
87 folder_path_qt_dir = os.path.dirname(folder_path_utils_dir)
88@@ -53,7 +74,9 @@
89 def test_execute_uninstall_on_licence_cancel_frozen(self):
90 """Pressing Disagree button from license page the uninstall is exec."""
91 self.patch(win32api, "ShellExecute", self._set_called)
92+ self.patch(os.path, "exists", lambda path: True)
93 sys.frozen = True
94+ self.addCleanup(delattr, sys, "frozen")
95 utils.uninstall_application()
96 self.assertTrue(self._called[0][0] is None)
97 self.assertTrue("uninstall.exe" in self._called[0][2])
98
99=== modified file 'ubuntuone_installer/gui/qt/utils/windows.py'
100--- ubuntuone_installer/gui/qt/utils/windows.py 2011-08-30 14:11:48 +0000
101+++ ubuntuone_installer/gui/qt/utils/windows.py 2011-09-01 18:28:36 +0000
102@@ -38,9 +38,10 @@
103 exec_path = os.path.dirname(__file__)
104 folder = os.path.dirname(exec_path)
105 uninstall_path = os.path.join(os.path.dirname(folder), "uninstall.exe")
106- win32api.ShellExecute(None, 'runas',
107- uninstall_path,
108- '--mode qt', '', 0)
109+ if os.path.exists(uninstall_path):
110+ win32api.ShellExecute(None, 'runas',
111+ uninstall_path,
112+ '--mode qt', '', 0)
113
114
115 def start_control_panel():

Subscribers

People subscribed via source and target branches