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 | 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(): |
+1