Merge lp:~nataliabidart/ubuntuone-control-panel/better-path-handling into lp:ubuntuone-control-panel

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 129
Merged at revision: 126
Proposed branch: lp:~nataliabidart/ubuntuone-control-panel/better-path-handling
Merge into: lp:ubuntuone-control-panel
Diff against target: 76 lines (+40/-1)
2 files modified
ubuntuone/controlpanel/gtk/gui.py (+12/-1)
ubuntuone/controlpanel/gtk/tests/test_gui.py (+28/-0)
To merge this branch: bzr merge lp:~nataliabidart/ubuntuone-control-panel/better-path-handling
Reviewer Review Type Date Requested Status
Eric Casteleijn (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+56264@code.launchpad.net

Commit message

- Do a more robust path handling when double clicking on the volumes tree view (LP: #728601, LP: #718407).

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

+1 yes, this is more robust, but something is broken on syncdaemon if it's passing None there.

review: Approve
Revision history for this message
Eric Casteleijn (thisfred) wrote :

Looks good

review: Approve
Revision history for this message
Natalia Bidart (nataliabidart) wrote :
Download full text (198.2 KiB)

The attempt to merge lp:~nataliabidart/ubuntuone-control-panel/better-path-handling into lp:ubuntuone-control-panel failed. Below is the output from the failed tests.

Running test suite for ubuntuone/controlpanel
Xlib: extension "RANDR" missing on display ":99".
ubuntuone.controlpanel.gtk.tests
  BaseTestCase
    runTest ... [OK]
ubuntuone.controlpanel.gtk.tests.test_gui_basic
  ControlPanelMixinTestCase
    test_is_a_control_panel_mixin ... [OK]
    test_ui_can_be_created ... [OK]
  ControlPanelTestCase
    test_backend_is_shutdown_on_close ... [OK]
    test_credentials_found_connects_syncdaemon ... [OK]
    test_credentials_found_shows_dashboard_panel ... [OK]
    test_credentials_found_shows_services_panel ... [OK]
    test_is_a_notebook ... [OK]
    test_local_device_removed_shows_overview_panel ... [OK]
    test_main_window_is_passed_to_child ... [OK]
    test_on_show_management_panel ... [OK]
    test_on_show_management_panel_is_idempotent ... [OK]
    test_overview_is_shown_at_startup ... [OK]
    test_startup_props ... [OK]
    test_startup_visibility ... [OK]
  ControlPanelWindowAlertParamTestCase
    test_alert ... [OK]
  ControlPanelWindowInvalidParamsTestCase
    test_closing_stops_the_main_lopp ... [OK]
    test_control_panel_is_the_only_child ... [OK]
    test_icon_name_is_correct ... [OK]
    test_is_a_window ... [OK]
    test_main_start_gtk_main_loop ... [OK]
    test_main_window_is_passed_to_child ... [OK]
    test_max_size ... [OK]
    test_startup_visibility ... [OK]
    test_switch_to ... [OK]
    test_title_is_correct ... [OK]
  ControlPanelWindowParamsNoneTestCase
    test_closing_stops_the_main_lopp ... [OK]
    test_control_panel_is_the_only_child ... [OK]
    test_icon_name_is_correct ... [OK]
    test_is_a_window ... [OK]
    test_main_start_gtk_main_loop ... [OK]
    test_main_window_is_passed_to_child ... [OK]
    test_max_size ... [OK]
    test_startup_visibility ...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone/controlpanel/gtk/gui.py'
2--- ubuntuone/controlpanel/gtk/gui.py 2011-04-04 20:36:59 +0000
3+++ ubuntuone/controlpanel/gtk/gui.py 2011-04-04 22:35:48 +0000
4@@ -551,6 +551,10 @@
5 elif name == self.MUSIC_DISPLAY_NAME:
6 icon_name = self.MUSIC_ICON_NAME
7
8+ if volume[u'path'] is None:
9+ logger.warning('on_volumes_info_ready: about to store a '
10+ 'volume with None path: %r', volume)
11+
12 row = (name, bool(volume[u'subscribed']), icon_name, True,
13 sensitive, gtk.ICON_SIZE_MENU, volume['volume_id'],
14 volume[u'path'])
15@@ -607,7 +611,14 @@
16 """The user double clicked on a row."""
17 treeiter = self.volumes_store.get_iter(path)
18 volume_path = self.volumes_store.get_value(treeiter, 7)
19- uri_hook(None, FILE_URI_PREFIX + volume_path)
20+ if volume_path is None:
21+ logger.warning('on_volumes_view_row_activated: volume_path for '
22+ 'tree_path %r is None', path)
23+ elif not os.path.exists(volume_path):
24+ logger.warning('on_volumes_view_row_activated: path %r '
25+ 'does not exist', volume_path)
26+ else:
27+ uri_hook(None, FILE_URI_PREFIX + volume_path)
28
29 def load(self):
30 """Load the volume list."""
31
32=== modified file 'ubuntuone/controlpanel/gtk/tests/test_gui.py'
33--- ubuntuone/controlpanel/gtk/tests/test_gui.py 2011-04-04 18:11:34 +0000
34+++ ubuntuone/controlpanel/gtk/tests/test_gui.py 2011-04-04 22:35:48 +0000
35@@ -278,6 +278,7 @@
36
37 def test_clicking_on_row_opens_folder(self):
38 """The folder activated is opened."""
39+ self.patch(gui.os.path, 'exists', lambda *a: True)
40 self.patch(gui, 'uri_hook', self._set_called)
41 self.ui.on_volumes_info_ready(FAKE_VOLUMES_INFO)
42
43@@ -287,6 +288,33 @@
44 self.assertEqual(self._called,
45 ((None, gui.FILE_URI_PREFIX + ROOT['path']), {}))
46
47+ def test_clicking_on_row_handles_path_none(self):
48+ """None paths are properly handled."""
49+ self.patch(gui, 'uri_hook', self._set_called)
50+ self.patch(self.ui.volumes_store, 'get_value', lambda *a: None)
51+ self.ui.on_volumes_info_ready(FAKE_VOLUMES_INFO)
52+
53+ self.ui.volumes_view.row_activated('0:0',
54+ self.ui.volumes_view.get_column(0))
55+
56+ self.assertTrue(self.memento.check_warning('tree_path (0, 0)',
57+ 'volume_path', 'is None'))
58+ self.assertEqual(self._called, False)
59+
60+ def test_clicking_on_row_handles_path_non_existent(self):
61+ """Not-existent paths are properly handled."""
62+ self.patch(gui.os.path, 'exists', lambda *a: False)
63+ self.patch(gui, 'uri_hook', self._set_called)
64+ path = 'not-in-disk'
65+ self.patch(self.ui.volumes_store, 'get_value', lambda *a: path)
66+ self.ui.on_volumes_info_ready(FAKE_VOLUMES_INFO)
67+
68+ self.ui.volumes_view.row_activated('0:0',
69+ self.ui.volumes_view.get_column(0))
70+
71+ self.assertTrue(self.memento.check_warning(path, 'does not exist'))
72+ self.assertEqual(self._called, False)
73+
74 def test_on_volumes_info_ready_with_music_folder(self):
75 """The volumes info is processed when ready."""
76 info = [(u'', u'147852369', [ROOT] + [MUSIC_FOLDER])]

Subscribers

People subscribed via source and target branches