Merge lp:~mandel/ubuntuone-control-panel/auto-update-looping-call into lp:ubuntuone-control-panel
| Status: | Rejected |
|---|---|
| Rejected by: | Manuel de la Peña on 2012-04-20 |
| Proposed branch: | lp:~mandel/ubuntuone-control-panel/auto-update-looping-call |
| Merge into: | lp:ubuntuone-control-panel |
| Prerequisite: | lp:~mandel/ubuntuone-control-panel/auto-update-functions |
| Diff against target: |
834 lines (+488/-115) 15 files modified
setup.py (+1/-0) ubuntuone/controlpanel/gui/__init__.py (+2/-0) ubuntuone/controlpanel/gui/qt/gui.py (+13/-0) ubuntuone/controlpanel/gui/qt/main/__init__.py (+1/-1) ubuntuone/controlpanel/gui/qt/systray.py (+17/-0) ubuntuone/controlpanel/gui/qt/task/__init__.py (+30/-0) ubuntuone/controlpanel/gui/qt/task/linux.py (+54/-0) ubuntuone/controlpanel/gui/qt/task/tests/__init__.py (+17/-0) ubuntuone/controlpanel/gui/qt/task/tests/test_linux.py (+82/-0) ubuntuone/controlpanel/gui/qt/tests/test_gui.py (+132/-0) ubuntuone/controlpanel/gui/qt/tests/test_start.py (+0/-108) ubuntuone/controlpanel/gui/qt/tests/test_systray.py (+77/-5) ubuntuone/controlpanel/utils/__init__.py (+4/-0) ubuntuone/controlpanel/utils/tests/test_windows.py (+46/-1) ubuntuone/controlpanel/utils/windows.py (+12/-0) |
| To merge this branch: | bzr merge lp:~mandel/ubuntuone-control-panel/auto-update-looping-call |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Natalia Bidart | 2011-11-02 | Needs Fixing on 2012-01-23 | |
| Alejandro J. Cura (community) | Needs Fixing on 2012-01-23 | ||
|
Review via email:
|
|||
Commit Message
Provides the code so that there is a looping call in the control panel that will check for update of the application.
Description of the Change
Provides the code so that there is a looping call in the control panel that will check for update of the application.
| Manuel de la Peña (mandel) wrote : | # |
> This style of coding tests is very ugly and error prone:
>
> 534 + def _clean_
> 535 + """Clean the fake window class."""
> 536 + FakeMainWindow.
> 537 + FakeMainWindow.
> 538 +
> 539 + def _clean_
> 540 + """Clean the fake icon class."""
> 541 + FakeTrayIcon.window = None
> 542 + FakeTrayIcon.
> 543 +
> 544 + def _clean_
> 545 + """Clean the fake looping call class."""
> 546 + FakeLoopingCall
> 547 + FakeLoopingCall
> 548 + FakeLoopingCall
> 549 + FakeLoopingCall
>
> Instead of patching with a class that gets its attributes overwritten, please
> patch with an instance that gets thrown away, so there's no need to reset the
> class attributes like in the code above.
>
> For instance:
> "self.patch(gui, 'LoopingCall', FakeLoopingCall)" ->
> "self.patch(gui, 'LoopingCall', FakeLoopingCall
>
> This is present a few times in this branch, so make sure all occurrences end
> up fixed.
>
Fixed them on ubuntuone/
> ---
>
> Also, to test code that uses LoopingCalls (and reactor.callLaters, too)
> remember that you can use twisted.
> LoopingCall.clock attribute. Then you will be able to fake the reactor moving
> forward in time by calling clock.advance.
>
> This gives you a lot of flexibility to test this kind of code, and the tests
> end up a lot faster and reliable than if they were using a small value for the
> LoopingCall or callLater time.
In my tests I'm asserting that the Looping call was indeed instantiated and started and I trust that the twisted implementation will be correct. I don't think I really need to move the clock to assert that the function was indeed called since the branch this branch depends on already tests that function.
I prefer not to force looping calls to be called since I find those types of tests to be integration tests. I'll leave the tests as they are so we can have a conversation later.
- 251. By Manuel de la Peña on 2011-11-14
-
Merged with parent.
- 252. By Manuel de la Peña on 2011-11-14
-
Fixed tests.
- 253. By Manuel de la Peña on 2011-11-14
-
Ensure __call__ returns self.
- 254. By Manuel de la Peña on 2011-11-16
-
Merged with parent and fixed conflicts.
- 255. By Manuel de la Peña on 2011-11-16
-
Resolve conflicts.
- 256. By Manuel de la Peña on 2011-11-16
-
Fixed lint issues.
- 257. By Manuel de la Peña on 2011-11-16
-
Removed all unecesary tests.
| Natalia Bidart (nataliabidart) wrote : | # |
This import code:
from ubuntuone.
AUTOUPDATE_
)
should be:
from ubuntuone.
autoupdate,
AUTOUPDATE_
)
Also, in ubuntuone/
47 - if with_icon or minimized:
48 + if with_icon:
| Manuel de la Peña (mandel) wrote : | # |
Looking at the code you will see that we had:
46 if not minimized:
47 - if with_icon or minimized:
so if minimized = False we go through the if at line 46 we have that an x or False == x, right?
- 258. By Manuel de la Peña on 2011-12-01
-
Merged with trunk.
- 259. By Manuel de la Peña on 2011-12-01
-
Fix the order of the import.
| Alejandro J. Cura (alecu) wrote : | # |
The TrayIcon constructor takes a LoopingCall as a parameter, but it's never used in production code.
It should be either removed or used.
---
Both FakeMainWindow and FakeTrayIcon are modifying the class attributes.
For instance:
FakeMainWind
The tests should be operating on object instances instead of classes, since modifying classes is bad form and causes maintenance issues.
- 260. By Manuel de la Peña on 2011-12-01
-
Create an assign in the same statement.
- 261. By Manuel de la Peña on 2011-12-14
-
Reviews changes:Improved the tests not to use the class attrs.
Removed unused __init__ parameter. - 262. By Manuel de la Peña on 2011-12-14
-
Fixed bug qhen calling the lc.
- 263. By Manuel de la Peña on 2011-12-14
-
Fixed qt tray tests.
- 264. By Manuel de la Peña on 2011-12-14
-
Fixed broken test after changes in FakeWindow.
- 265. By Manuel de la Peña on 2012-01-23
-
Merged with trunk and fixed conflicts.
- 266. By Manuel de la Peña on 2012-01-23
-
Fixed tests so that they work when using the FakeSdTool.
- 267. By Manuel de la Peña on 2012-01-23
-
Fixed some small lint issues.
| Alejandro J. Cura (alecu) wrote : | # |
I've just been warned by nessita that if we land this branch it will mean that the qt control panel on linux will need the qt4reactor, and we are trying to move away from it.
Nessita will add more details to this bug.
| Natalia Bidart (nataliabidart) wrote : | # |
* The file ubuntuone/
* Also, like alecu mentioned, we are working on having the QT control panel running only a Qt main loop in Linux, since we need to drop the dependency on the qt4reactor in that OS because we can't file a MIR for it (at least for now). So, since the autoupdate code is only relevant to windows, we'd need to move all that (included the LoopingCall, which brings in the need of a twisted reactor) to a windows-specific location, for example, main/windows.py.
I'd suggest to move the 'start' method to the 'main/' python package, and have all the autoupdate code moved to main/windows.py.
Sorry if I was not explicit about this before, but the goal of dropping the qt4reactor in Linux is a rather new objective.
Let me know if you need further assistance!
Thanks.
| Manuel de la Peña (mandel) wrote : | # |
> * The file ubuntuone/
> this branch is changing the EOLs to windows style, and we should have unix
> EOLs in all the files.
>
Hm.. strange I used vim on linux to edit that.. let me double check and make sure its ok.
> * Also, like alecu mentioned, we are working on having the QT control panel
> running only a Qt main loop in Linux, since we need to drop the dependency on
> the qt4reactor in that OS because we can't file a MIR for it (at least for
> now). So, since the autoupdate code is only relevant to windows, we'd need to
> move all that (included the LoopingCall, which brings in the need of a twisted
> reactor) to a windows-specific location, for example, main/windows.py.
>
> I'd suggest to move the 'start' method to the 'main/' python package, and have
> all the autoupdate code moved to main/windows.py.
>
> Sorry if I was not explicit about this before, but the goal of dropping the
> qt4reactor in Linux is a rather new objective.
>
> Let me know if you need further assistance!
> Thanks.
Sure, no problem, its a rather old branch so moving qt to linux is a new thing. I'll get it fix for today.
- 268. By Manuel de la Peña on 2012-01-24
-
Removed the need to import the reactor from the systray.
- 269. By Manuel de la Peña on 2012-01-24
-
Fixed the start tests that failed due to changes in the API.
- 270. By Manuel de la Peña on 2012-01-24
-
Added a looping call for the linux implementation based on QTimer.
- 271. By Manuel de la Peña on 2012-01-24
-
Face palm.
- 272. By Manuel de la Peña on 2012-01-24
-
Added tests for the linux LoopingCall.
- 273. By Manuel de la Peña on 2012-01-24
-
Face palm.
- 274. By Manuel de la Peña on 2012-01-24
-
_execute required to have self passed.
- 275. By Manuel de la Peña on 2012-01-24
-
Fixed tests.
- 276. By Manuel de la Peña on 2012-01-24
-
Got all tests working correctly.
| Manuel de la Peña (mandel) wrote : | # |
I have applied changes to the code to simplify the move away from the qt4reactor, please let me know if they are goo enough:
* Removed the import of stop in the systray (present in trunk). Because we pass the stop function to main lets just foward that to systray.
* Added a LoopingCall object that uses QTimer for linux since we won't be using the reactor. Added tests to ensure if works as a LoopingCall (including same assert exceptions.)
* dos2unix used in the files with windows EOL.
- 277. By Manuel de la Peña on 2012-01-24
-
Moved start to a diff location so that we do not drag the qt reactor with us.
- 278. By Manuel de la Peña on 2012-01-24
-
Merged with parent.
- 279. By Manuel de la Peña on 2012-01-24
-
Added tests for start.
- 280. By Manuel de la Peña on 2012-01-24
-
Fixed tests on windows.
- 281. By Manuel de la Peña on 2012-01-25
-
Always perform the auto update looping call.
- 282. By Manuel de la Peña on 2012-01-25
-
Fixed lint issues.
- 283. By Manuel de la Peña on 2012-01-25
-
Updated copyrighs.
- 284. By Manuel de la Peña on 2012-01-25
-
Removed the pep8 issue.
- 285. By Manuel de la Peña on 2012-03-29
-
Merged with trunk and fixed all the conflicts.
- 286. By Manuel de la Peña on 2012-03-30
-
Moved looping call to a task package.
- 287. By Manuel de la Peña on 2012-03-30
-
Merged and resolve conflicts with the unsintall branch.
- 288. By Manuel de la Peña on 2012-03-30
-
Added the tests to the correct location. Updated setup.py
- 289. By Manuel de la Peña on 2012-03-30
-
Set the value of the looping call.
Unmerged revisions
- 289. By Manuel de la Peña on 2012-03-30
-
Set the value of the looping call.
- 288. By Manuel de la Peña on 2012-03-30
-
Added the tests to the correct location. Updated setup.py
- 287. By Manuel de la Peña on 2012-03-30
-
Merged and resolve conflicts with the unsintall branch.
- 286. By Manuel de la Peña on 2012-03-30
-
Moved looping call to a task package.
- 285. By Manuel de la Peña on 2012-03-29
-
Merged with trunk and fixed all the conflicts.
- 284. By Manuel de la Peña on 2012-01-25
-
Removed the pep8 issue.
- 283. By Manuel de la Peña on 2012-01-25
-
Updated copyrighs.
- 282. By Manuel de la Peña on 2012-01-25
-
Fixed lint issues.
- 281. By Manuel de la Peña on 2012-01-25
-
Always perform the auto update looping call.
- 280. By Manuel de la Peña on 2012-01-24
-
Fixed tests on windows.


This style of coding tests is very ugly and error prone:
534 + def _clean_ fake_window_ class(self) : called = [] close_callback = None fake_icon_ class(self) : auto_update = None fake_looping_ call_class( self): .function = None .args = None .kwargs = None .called = []
535 + """Clean the fake window class."""
536 + FakeMainWindow.
537 + FakeMainWindow.
538 +
539 + def _clean_
540 + """Clean the fake icon class."""
541 + FakeTrayIcon.window = None
542 + FakeTrayIcon.
543 +
544 + def _clean_
545 + """Clean the fake looping call class."""
546 + FakeLoopingCall
547 + FakeLoopingCall
548 + FakeLoopingCall
549 + FakeLoopingCall
Instead of patching with a class that gets its attributes overwritten, please patch with an instance that gets thrown away, so there's no need to reset the class attributes like in the code above.
For instance: Class() )"
"self.patch(gui, 'LoopingCall', FakeLoopingCall)" ->
"self.patch(gui, 'LoopingCall', FakeLoopingCall
This is present a few times in this branch, so make sure all occurrences end up fixed.
---
Also, to test code that uses LoopingCalls (and reactor.callLaters, too) remember that you can use twisted. internet. task.Clock, by patching the LoopingCall.clock attribute. Then you will be able to fake the reactor moving forward in time by calling clock.advance.
This gives you a lot of flexibility to test this kind of code, and the tests end up a lot faster and reliable than if they were using a small value for the LoopingCall or callLater time.