Merge lp:~diegosarmentero/ubuntuone-windows-installer/close-on-license into lp:ubuntuone-windows-installer
- close-on-license
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Natalia Bidart (community) | Approve | ||
Roberto Alsina (community) | Approve | ||
Review via email:
|
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.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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:
* Same for this code, we need to restore the env like it was before the test run:
if hasattr(sys, "frozen"):
should migrate to something like:
frozen = getattr(sys, "frozen", None)
if frozen is not None:
* 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:
with:
Also, this code:
can morph into (is easier to read, no need to scroll up to see what does fake_caller is/does):
Thanks!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Natalia Bidart (nataliabidart) wrote : | # |
There seems to be a conflict now that ralsina's fix-tests branch landed.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Natalia Bidart (nataliabidart) wrote : | # |
* This does not work:
self.addCleanup
addCleanup receives a function, so it should be:
self.addCleanup
* This self.addCleanup
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Natalia Bidart (nataliabidart) wrote : | # |
Why you're asserting this?
self.assertFals
I would expect the test to assert self.assertFals
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Diego Sarmentero (diegosarmentero) wrote : | # |
> Why you're asserting this?
>
> self.assertFals
>
> I would expect the test to assert self.assertFals
> 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.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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(
26 """Basics for testing."""
27
28 assertIs = BaseTestCase.
29
30 def setUp(self):
31 self._called = False
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Natalia Bidart (nataliabidart) wrote : | # |
Looks good! Please remove the unneeded call to setUp.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ubuntu One Auto Pilot (otto-pilot) wrote : | # |
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/
Compiled data/qt/
Compiled data/qt/
compiled data/qt/images.qrc into ubuntuone_
Compiled data/qt/folders.ui into ubuntuone_
Compiled data/qt/
Compiled data/qt/license.ui into ubuntuone_
Compiled data/qt/
Compiled data/qt/
Compiled data/qt/sign_in.ui into ubuntuone_
Compiled data/qt/
Compiled data/qt/
running build_py
creating build
creating build/lib.
creating build/lib.
copying ubuntuone_
copying ubuntuone_
creating build/lib.
copying ubuntuone_
creating build/lib.
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
running build_scripts
creating build/scripts-2.7
copying and adjusting bin/ubuntuone-
changing mode of build/scripts-
running build_i18n
intltoo...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ubuntu One Auto Pilot (otto-pilot) wrote : | # |
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/
Compiled data/qt/
Compiled data/qt/
compiled data/qt/images.qrc into ubuntuone_
Compiled data/qt/folders.ui into ubuntuone_
Compiled data/qt/
Compiled data/qt/license.ui into ubuntuone_
Compiled data/qt/
Compiled data/qt/
Compiled data/qt/sign_in.ui into ubuntuone_
Compiled data/qt/
Compiled data/qt/
running build_py
creating build
creating build/lib.
creating build/lib.
copying ubuntuone_
copying ubuntuone_
creating build/lib.
copying ubuntuone_
creating build/lib.
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
running build_scripts
creating build/scripts-2.7
copying and adjusting bin/ubuntuone-
changing mode of build/scripts-
running build_i18n
intltoo...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ubuntu One Auto Pilot (otto-pilot) wrote : | # |
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/
Compiled data/qt/
Compiled data/qt/
compiled data/qt/images.qrc into ubuntuone_
Compiled data/qt/folders.ui into ubuntuone_
Compiled data/qt/
Compiled data/qt/license.ui into ubuntuone_
Compiled data/qt/
Compiled data/qt/
Compiled data/qt/sign_in.ui into ubuntuone_
Compiled data/qt/
Compiled data/qt/
running build_py
creating build
creating build/lib.
creating build/lib.
copying ubuntuone_
copying ubuntuone_
creating build/lib.
copying ubuntuone_
creating build/lib.
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
copying ubuntuone_
running build_scripts
creating build/scripts-2.7
copying and adjusting bin/ubuntuone-
changing mode of build/scripts-
running build_i18n
intltoo...
Preview Diff
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 | 28 | NO_OP = lambda *args: None | 28 | NO_OP = lambda *args: None |
6 | 29 | 29 | ||
7 | 30 | 30 | ||
8 | 31 | def skip_if_abstract_class(test): | ||
9 | 32 | """Decorator to skip a test if is an abstract class.""" | ||
10 | 33 | |||
11 | 34 | def inner(instance): | ||
12 | 35 | """Skip a test if is an abstract class.""" | ||
13 | 36 | abstract = instance.class_ui is None | ||
14 | 37 | result = None | ||
15 | 38 | if not abstract: | ||
16 | 39 | result = test(instance) | ||
17 | 40 | |||
18 | 41 | return result | ||
19 | 42 | |||
20 | 43 | return inner | ||
21 | 44 | |||
22 | 45 | |||
23 | 46 | class FakeUi(FakedObject): | 31 | class FakeUi(FakedObject): |
24 | 47 | """A fake Ui object.""" | 32 | """A fake Ui object.""" |
25 | 48 | 33 | ||
26 | @@ -55,13 +40,14 @@ | |||
27 | 55 | class_ui = None | 40 | class_ui = None |
28 | 56 | kwargs = {} | 41 | kwargs = {} |
29 | 57 | 42 | ||
30 | 58 | @skip_if_abstract_class | ||
31 | 59 | def setUp(self): | 43 | def setUp(self): |
32 | 60 | super(BaseTestCase, self).setUp() | 44 | super(BaseTestCase, self).setUp() |
33 | 61 | # self.class_ui is not callable | 45 | # self.class_ui is not callable |
34 | 62 | # pylint: disable=E1102 | 46 | # pylint: disable=E1102 |
35 | 63 | # pylint: disable=C0103 | 47 | # pylint: disable=C0103 |
37 | 64 | self.ui = self.class_ui(**self.kwargs) | 48 | self.ui = None |
38 | 49 | if self.class_ui is not None: | ||
39 | 50 | self.ui = self.class_ui(**self.kwargs) | ||
40 | 65 | 51 | ||
41 | 66 | if hasattr(self.ui, 'backend'): | 52 | if hasattr(self.ui, 'backend'): |
42 | 67 | # clean backend calls | 53 | # clean backend calls |
43 | 68 | 54 | ||
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 | 31 | 31 | ||
49 | 32 | 32 | ||
50 | 33 | class UninstallerTestCase(BaseTestCase): | 33 | class UninstallerTestCase(BaseTestCase): |
51 | 34 | |||
52 | 35 | """Test the uninstaller.""" | 34 | """Test the uninstaller.""" |
53 | 36 | 35 | ||
54 | 36 | def test_execute_uninstall_on_licence_cancel_file_not_exists(self): | ||
55 | 37 | """Pressing Disagree button from license page the uninstall is exec.""" | ||
56 | 38 | # If it's frozen this test fails because the path | ||
57 | 39 | # depends on the location of the exe | ||
58 | 40 | frozen = getattr(sys, "frozen", None) | ||
59 | 41 | if frozen is not None: | ||
60 | 42 | delattr(sys, "frozen") | ||
61 | 43 | self.addCleanup(setattr, sys, 'frozen', frozen) | ||
62 | 44 | self.patch(win32api, "ShellExecute", self._set_called) | ||
63 | 45 | self.assertFalse(self._called) | ||
64 | 46 | |||
65 | 47 | def test_execute_uninstall_on_licence_cancel_frozen_file_not_exists(self): | ||
66 | 48 | """Pressing Disagree button from license page the uninstall is exec.""" | ||
67 | 49 | self.patch(win32api, "ShellExecute", self._set_called) | ||
68 | 50 | sys.frozen = True | ||
69 | 51 | self.addCleanup(delattr, sys, "frozen") | ||
70 | 52 | utils.uninstall_application() | ||
71 | 53 | self.assertFalse(self._called) | ||
72 | 54 | |||
73 | 37 | def test_execute_uninstall_on_licence_cancel(self): | 55 | def test_execute_uninstall_on_licence_cancel(self): |
74 | 38 | """Pressing Disagree button from license page the uninstall is exec.""" | 56 | """Pressing Disagree button from license page the uninstall is exec.""" |
75 | 39 | self.patch(win32api, "ShellExecute", self._set_called) | 57 | self.patch(win32api, "ShellExecute", self._set_called) |
76 | 58 | self.patch(os.path, "exists", lambda path: True) | ||
77 | 40 | utils.uninstall_application() | 59 | utils.uninstall_application() |
78 | 41 | # If it's frozen this test fails because the path | 60 | # If it's frozen this test fails because the path |
79 | 42 | # depends on the location of the exe | 61 | # depends on the location of the exe |
81 | 43 | if hasattr(sys, "frozen"): | 62 | frozen = getattr(sys, "frozen", None) |
82 | 63 | if frozen is not None: | ||
83 | 44 | delattr(sys, "frozen") | 64 | delattr(sys, "frozen") |
84 | 65 | self.addCleanup(setattr, sys, 'frozen', frozen) | ||
85 | 45 | exec_path = os.path.abspath(__file__) | 66 | exec_path = os.path.abspath(__file__) |
86 | 46 | folder_path_utils_dir = os.path.dirname(exec_path) | 67 | folder_path_utils_dir = os.path.dirname(exec_path) |
87 | 47 | folder_path_qt_dir = os.path.dirname(folder_path_utils_dir) | 68 | folder_path_qt_dir = os.path.dirname(folder_path_utils_dir) |
88 | @@ -53,7 +74,9 @@ | |||
89 | 53 | def test_execute_uninstall_on_licence_cancel_frozen(self): | 74 | def test_execute_uninstall_on_licence_cancel_frozen(self): |
90 | 54 | """Pressing Disagree button from license page the uninstall is exec.""" | 75 | """Pressing Disagree button from license page the uninstall is exec.""" |
91 | 55 | self.patch(win32api, "ShellExecute", self._set_called) | 76 | self.patch(win32api, "ShellExecute", self._set_called) |
92 | 77 | self.patch(os.path, "exists", lambda path: True) | ||
93 | 56 | sys.frozen = True | 78 | sys.frozen = True |
94 | 79 | self.addCleanup(delattr, sys, "frozen") | ||
95 | 57 | utils.uninstall_application() | 80 | utils.uninstall_application() |
96 | 58 | self.assertTrue(self._called[0][0] is None) | 81 | self.assertTrue(self._called[0][0] is None) |
97 | 59 | self.assertTrue("uninstall.exe" in self._called[0][2]) | 82 | self.assertTrue("uninstall.exe" in self._called[0][2]) |
98 | 60 | 83 | ||
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 | 38 | exec_path = os.path.dirname(__file__) | 38 | exec_path = os.path.dirname(__file__) |
104 | 39 | folder = os.path.dirname(exec_path) | 39 | folder = os.path.dirname(exec_path) |
105 | 40 | uninstall_path = os.path.join(os.path.dirname(folder), "uninstall.exe") | 40 | uninstall_path = os.path.join(os.path.dirname(folder), "uninstall.exe") |
109 | 41 | win32api.ShellExecute(None, 'runas', | 41 | if os.path.exists(uninstall_path): |
110 | 42 | uninstall_path, | 42 | win32api.ShellExecute(None, 'runas', |
111 | 43 | '--mode qt', '', 0) | 43 | uninstall_path, |
112 | 44 | '--mode qt', '', 0) | ||
113 | 44 | 45 | ||
114 | 45 | 46 | ||
115 | 46 | def start_control_panel(): | 47 | def start_control_panel(): |
+1