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
=== modified file 'ubuntuone_installer/gui/qt/tests/__init__.py'
--- ubuntuone_installer/gui/qt/tests/__init__.py 2011-06-22 10:47:08 +0000
+++ ubuntuone_installer/gui/qt/tests/__init__.py 2011-09-01 18:28:36 +0000
@@ -28,21 +28,6 @@
28NO_OP = lambda *args: None28NO_OP = lambda *args: None
2929
3030
31def skip_if_abstract_class(test):
32 """Decorator to skip a test if is an abstract class."""
33
34 def inner(instance):
35 """Skip a test if is an abstract class."""
36 abstract = instance.class_ui is None
37 result = None
38 if not abstract:
39 result = test(instance)
40
41 return result
42
43 return inner
44
45
46class FakeUi(FakedObject):31class FakeUi(FakedObject):
47 """A fake Ui object."""32 """A fake Ui object."""
4833
@@ -55,13 +40,14 @@
55 class_ui = None40 class_ui = None
56 kwargs = {}41 kwargs = {}
5742
58 @skip_if_abstract_class
59 def setUp(self):43 def setUp(self):
60 super(BaseTestCase, self).setUp()44 super(BaseTestCase, self).setUp()
61 # self.class_ui is not callable45 # self.class_ui is not callable
62 # pylint: disable=E110246 # pylint: disable=E1102
63 # pylint: disable=C010347 # pylint: disable=C0103
64 self.ui = self.class_ui(**self.kwargs)48 self.ui = None
49 if self.class_ui is not None:
50 self.ui = self.class_ui(**self.kwargs)
6551
66 if hasattr(self.ui, 'backend'):52 if hasattr(self.ui, 'backend'):
67 # clean backend calls53 # clean backend calls
6854
=== modified file 'ubuntuone_installer/gui/qt/utils/tests/test_windows.py'
--- ubuntuone_installer/gui/qt/utils/tests/test_windows.py 2011-08-30 14:11:48 +0000
+++ ubuntuone_installer/gui/qt/utils/tests/test_windows.py 2011-09-01 18:28:36 +0000
@@ -31,17 +31,38 @@
3131
3232
33class UninstallerTestCase(BaseTestCase):33class UninstallerTestCase(BaseTestCase):
34
35 """Test the uninstaller."""34 """Test the uninstaller."""
3635
36 def test_execute_uninstall_on_licence_cancel_file_not_exists(self):
37 """Pressing Disagree button from license page the uninstall is exec."""
38 # If it's frozen this test fails because the path
39 # depends on the location of the exe
40 frozen = getattr(sys, "frozen", None)
41 if frozen is not None:
42 delattr(sys, "frozen")
43 self.addCleanup(setattr, sys, 'frozen', frozen)
44 self.patch(win32api, "ShellExecute", self._set_called)
45 self.assertFalse(self._called)
46
47 def test_execute_uninstall_on_licence_cancel_frozen_file_not_exists(self):
48 """Pressing Disagree button from license page the uninstall is exec."""
49 self.patch(win32api, "ShellExecute", self._set_called)
50 sys.frozen = True
51 self.addCleanup(delattr, sys, "frozen")
52 utils.uninstall_application()
53 self.assertFalse(self._called)
54
37 def test_execute_uninstall_on_licence_cancel(self):55 def test_execute_uninstall_on_licence_cancel(self):
38 """Pressing Disagree button from license page the uninstall is exec."""56 """Pressing Disagree button from license page the uninstall is exec."""
39 self.patch(win32api, "ShellExecute", self._set_called)57 self.patch(win32api, "ShellExecute", self._set_called)
58 self.patch(os.path, "exists", lambda path: True)
40 utils.uninstall_application()59 utils.uninstall_application()
41 # If it's frozen this test fails because the path60 # If it's frozen this test fails because the path
42 # depends on the location of the exe61 # depends on the location of the exe
43 if hasattr(sys, "frozen"):62 frozen = getattr(sys, "frozen", None)
63 if frozen is not None:
44 delattr(sys, "frozen")64 delattr(sys, "frozen")
65 self.addCleanup(setattr, sys, 'frozen', frozen)
45 exec_path = os.path.abspath(__file__)66 exec_path = os.path.abspath(__file__)
46 folder_path_utils_dir = os.path.dirname(exec_path)67 folder_path_utils_dir = os.path.dirname(exec_path)
47 folder_path_qt_dir = os.path.dirname(folder_path_utils_dir)68 folder_path_qt_dir = os.path.dirname(folder_path_utils_dir)
@@ -53,7 +74,9 @@
53 def test_execute_uninstall_on_licence_cancel_frozen(self):74 def test_execute_uninstall_on_licence_cancel_frozen(self):
54 """Pressing Disagree button from license page the uninstall is exec."""75 """Pressing Disagree button from license page the uninstall is exec."""
55 self.patch(win32api, "ShellExecute", self._set_called)76 self.patch(win32api, "ShellExecute", self._set_called)
77 self.patch(os.path, "exists", lambda path: True)
56 sys.frozen = True78 sys.frozen = True
79 self.addCleanup(delattr, sys, "frozen")
57 utils.uninstall_application()80 utils.uninstall_application()
58 self.assertTrue(self._called[0][0] is None)81 self.assertTrue(self._called[0][0] is None)
59 self.assertTrue("uninstall.exe" in self._called[0][2])82 self.assertTrue("uninstall.exe" in self._called[0][2])
6083
=== modified file 'ubuntuone_installer/gui/qt/utils/windows.py'
--- ubuntuone_installer/gui/qt/utils/windows.py 2011-08-30 14:11:48 +0000
+++ ubuntuone_installer/gui/qt/utils/windows.py 2011-09-01 18:28:36 +0000
@@ -38,9 +38,10 @@
38 exec_path = os.path.dirname(__file__)38 exec_path = os.path.dirname(__file__)
39 folder = os.path.dirname(exec_path)39 folder = os.path.dirname(exec_path)
40 uninstall_path = os.path.join(os.path.dirname(folder), "uninstall.exe")40 uninstall_path = os.path.join(os.path.dirname(folder), "uninstall.exe")
41 win32api.ShellExecute(None, 'runas',41 if os.path.exists(uninstall_path):
42 uninstall_path,42 win32api.ShellExecute(None, 'runas',
43 '--mode qt', '', 0)43 uninstall_path,
44 '--mode qt', '', 0)
4445
4546
46def start_control_panel():47def start_control_panel():

Subscribers

People subscribed via source and target branches