Merge lp:~nataliabidart/magicicada-gui/show-queue-state into lp:magicicada-gui
- show-queue-state
- Merge into trunk
Proposed by
Natalia Bidart
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Facundo Batista | ||||
Approved revision: | 26 | ||||
Merged at revision: | 25 | ||||
Proposed branch: | lp:~nataliabidart/magicicada-gui/show-queue-state | ||||
Merge into: | lp:magicicada-gui | ||||
Diff against target: |
544 lines (+211/-151) 3 files modified
data/ui/gui.glade (+161/-121) magicicada/__init__.py (+4/-2) magicicada/tests/test_magicicada.py (+46/-28) |
||||
To merge this branch: | bzr merge lp:~nataliabidart/magicicada-gui/show-queue-state | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
chicharreros | Pending | ||
Review via email: mp+25914@code.launchpad.net |
Commit message
Description of the change
Queue state is shown. Queues tree views have now title. Tests can now be run with trial.
To post a comment you must log in.
Revision history for this message
Facundo Batista (facundo) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'data/ui/gui.glade' |
2 | --- data/ui/gui.glade 2010-05-23 23:26:22 +0000 |
3 | +++ data/ui/gui.glade 2010-05-24 19:21:27 +0000 |
4 | @@ -119,7 +119,7 @@ |
5 | </child> |
6 | <child> |
7 | <object class="GtkToolButton" id="connect"> |
8 | - <property name="width_request">80</property> |
9 | + <property name="width_request">85</property> |
10 | <property name="visible">True</property> |
11 | <property name="sensitive">False</property> |
12 | <property name="label" translatable="yes">Connect</property> |
13 | @@ -134,7 +134,7 @@ |
14 | </child> |
15 | <child> |
16 | <object class="GtkToolButton" id="disconnect"> |
17 | - <property name="width_request">80</property> |
18 | + <property name="width_request">85</property> |
19 | <property name="label" translatable="yes">Disconnect</property> |
20 | <property name="use_underline">True</property> |
21 | <property name="stock_id">gtk-disconnect</property> |
22 | @@ -223,147 +223,187 @@ |
23 | <property name="visible">True</property> |
24 | <property name="can_focus">True</property> |
25 | <child> |
26 | - <object class="GtkScrolledWindow" id="scrolledwindow1"> |
27 | + <object class="GtkHBox" id="hbox3"> |
28 | <property name="visible">True</property> |
29 | - <property name="can_focus">True</property> |
30 | - <property name="hscrollbar_policy">automatic</property> |
31 | - <child> |
32 | - <object class="GtkTreeView" id="metaq_view"> |
33 | - <property name="visible">True</property> |
34 | - <property name="sensitive">False</property> |
35 | + <child> |
36 | + <object class="GtkLabel" id="label1"> |
37 | + <property name="visible">True</property> |
38 | + <property name="label" translatable="yes">Metadata Queue</property> |
39 | + <property name="angle">90</property> |
40 | + </object> |
41 | + <packing> |
42 | + <property name="expand">False</property> |
43 | + <property name="fill">False</property> |
44 | + <property name="position">0</property> |
45 | + </packing> |
46 | + </child> |
47 | + <child> |
48 | + <object class="GtkScrolledWindow" id="scrolledwindow1"> |
49 | + <property name="visible">True</property> |
50 | <property name="can_focus">True</property> |
51 | - <property name="model">metaq_store</property> |
52 | - <property name="headers_clickable">False</property> |
53 | - <property name="rules_hint">True</property> |
54 | - <property name="search_column">0</property> |
55 | - <property name="enable_grid_lines">both</property> |
56 | - <property name="enable_tree_lines">True</property> |
57 | - <child> |
58 | - <object class="GtkTreeViewColumn" id="metaq_operation"> |
59 | - <property name="resizable">True</property> |
60 | - <property name="title">Operation</property> |
61 | - <property name="expand">True</property> |
62 | - <child> |
63 | - <object class="GtkCellRendererText" id="cellrenderertext1"/> |
64 | - <attributes> |
65 | - <attribute name="text">0</attribute> |
66 | - </attributes> |
67 | - </child> |
68 | - </object> |
69 | - </child> |
70 | - <child> |
71 | - <object class="GtkTreeViewColumn" id="metaq_path"> |
72 | - <property name="title">Path</property> |
73 | - <property name="expand">True</property> |
74 | - <child> |
75 | - <object class="GtkCellRendererText" id="cellrenderertext2"/> |
76 | - <attributes> |
77 | - <attribute name="text">1</attribute> |
78 | - </attributes> |
79 | - </child> |
80 | - </object> |
81 | - </child> |
82 | - <child> |
83 | - <object class="GtkTreeViewColumn" id="metaq_node"> |
84 | - <property name="title">Node</property> |
85 | - <property name="expand">True</property> |
86 | - <child> |
87 | - <object class="GtkCellRendererText" id="cellrenderertext3"/> |
88 | - <attributes> |
89 | - <attribute name="text">2</attribute> |
90 | - </attributes> |
91 | - </child> |
92 | - </object> |
93 | - </child> |
94 | - <child> |
95 | - <object class="GtkTreeViewColumn" id="metaq_share"> |
96 | - <property name="title">Share</property> |
97 | - <property name="expand">True</property> |
98 | - <child> |
99 | - <object class="GtkCellRendererText" id="cellrenderertext4"/> |
100 | - <attributes> |
101 | - <attribute name="text">3</attribute> |
102 | - </attributes> |
103 | + <property name="hscrollbar_policy">automatic</property> |
104 | + <child> |
105 | + <object class="GtkTreeView" id="metaq_view"> |
106 | + <property name="visible">True</property> |
107 | + <property name="sensitive">False</property> |
108 | + <property name="can_focus">True</property> |
109 | + <property name="model">metaq_store</property> |
110 | + <property name="headers_clickable">False</property> |
111 | + <property name="rules_hint">True</property> |
112 | + <property name="search_column">0</property> |
113 | + <property name="enable_grid_lines">both</property> |
114 | + <property name="enable_tree_lines">True</property> |
115 | + <child> |
116 | + <object class="GtkTreeViewColumn" id="metaq_operation"> |
117 | + <property name="resizable">True</property> |
118 | + <property name="title">Operation</property> |
119 | + <property name="expand">True</property> |
120 | + <child> |
121 | + <object class="GtkCellRendererText" id="cellrenderertext1"/> |
122 | + <attributes> |
123 | + <attribute name="text">0</attribute> |
124 | + </attributes> |
125 | + </child> |
126 | + </object> |
127 | + </child> |
128 | + <child> |
129 | + <object class="GtkTreeViewColumn" id="metaq_path"> |
130 | + <property name="title">Path</property> |
131 | + <property name="expand">True</property> |
132 | + <child> |
133 | + <object class="GtkCellRendererText" id="cellrenderertext2"/> |
134 | + <attributes> |
135 | + <attribute name="text">1</attribute> |
136 | + </attributes> |
137 | + </child> |
138 | + </object> |
139 | + </child> |
140 | + <child> |
141 | + <object class="GtkTreeViewColumn" id="metaq_node"> |
142 | + <property name="title">Node</property> |
143 | + <property name="expand">True</property> |
144 | + <child> |
145 | + <object class="GtkCellRendererText" id="cellrenderertext3"/> |
146 | + <attributes> |
147 | + <attribute name="text">2</attribute> |
148 | + </attributes> |
149 | + </child> |
150 | + </object> |
151 | + </child> |
152 | + <child> |
153 | + <object class="GtkTreeViewColumn" id="metaq_share"> |
154 | + <property name="title">Share</property> |
155 | + <property name="expand">True</property> |
156 | + <child> |
157 | + <object class="GtkCellRendererText" id="cellrenderertext4"/> |
158 | + <attributes> |
159 | + <attribute name="text">3</attribute> |
160 | + </attributes> |
161 | + </child> |
162 | + </object> |
163 | </child> |
164 | </object> |
165 | </child> |
166 | </object> |
167 | + <packing> |
168 | + <property name="position">1</property> |
169 | + </packing> |
170 | </child> |
171 | </object> |
172 | <packing> |
173 | - <property name="resize">False</property> |
174 | + <property name="resize">True</property> |
175 | <property name="shrink">True</property> |
176 | </packing> |
177 | </child> |
178 | <child> |
179 | - <object class="GtkScrolledWindow" id="scrolledwindow2"> |
180 | + <object class="GtkHBox" id="hbox4"> |
181 | <property name="visible">True</property> |
182 | - <property name="can_focus">True</property> |
183 | - <property name="hscrollbar_policy">automatic</property> |
184 | - <child> |
185 | - <object class="GtkTreeView" id="contentq_view"> |
186 | - <property name="visible">True</property> |
187 | - <property name="sensitive">False</property> |
188 | + <child> |
189 | + <object class="GtkLabel" id="label2"> |
190 | + <property name="visible">True</property> |
191 | + <property name="label" translatable="yes">Content Queue</property> |
192 | + <property name="angle">90</property> |
193 | + </object> |
194 | + <packing> |
195 | + <property name="expand">False</property> |
196 | + <property name="fill">False</property> |
197 | + <property name="position">0</property> |
198 | + </packing> |
199 | + </child> |
200 | + <child> |
201 | + <object class="GtkScrolledWindow" id="scrolledwindow2"> |
202 | + <property name="visible">True</property> |
203 | <property name="can_focus">True</property> |
204 | - <property name="model">contentq_store</property> |
205 | - <property name="headers_clickable">False</property> |
206 | - <property name="rules_hint">True</property> |
207 | - <property name="search_column">0</property> |
208 | - <property name="enable_grid_lines">both</property> |
209 | - <property name="enable_tree_lines">True</property> |
210 | - <child> |
211 | - <object class="GtkTreeViewColumn" id="contentq_operation"> |
212 | - <property name="title">Operation</property> |
213 | - <property name="expand">True</property> |
214 | - <child> |
215 | - <object class="GtkCellRendererText" id="cellrenderertext5"/> |
216 | - <attributes> |
217 | - <attribute name="text">0</attribute> |
218 | - </attributes> |
219 | - </child> |
220 | - </object> |
221 | - </child> |
222 | - <child> |
223 | - <object class="GtkTreeViewColumn" id="contentq_path"> |
224 | - <property name="title">Path</property> |
225 | - <property name="expand">True</property> |
226 | - <child> |
227 | - <object class="GtkCellRendererText" id="cellrenderertext6"/> |
228 | - <attributes> |
229 | - <attribute name="text">1</attribute> |
230 | - </attributes> |
231 | - </child> |
232 | - </object> |
233 | - </child> |
234 | - <child> |
235 | - <object class="GtkTreeViewColumn" id="contentq_node"> |
236 | - <property name="title">Node</property> |
237 | - <property name="expand">True</property> |
238 | - <child> |
239 | - <object class="GtkCellRendererText" id="cellrenderertext7"/> |
240 | - <attributes> |
241 | - <attribute name="text">2</attribute> |
242 | - </attributes> |
243 | - </child> |
244 | - </object> |
245 | - </child> |
246 | - <child> |
247 | - <object class="GtkTreeViewColumn" id="contentq_share"> |
248 | - <property name="title">Share</property> |
249 | - <property name="expand">True</property> |
250 | - <child> |
251 | - <object class="GtkCellRendererText" id="cellrenderertext8"/> |
252 | - <attributes> |
253 | - <attribute name="text">3</attribute> |
254 | - </attributes> |
255 | + <property name="hscrollbar_policy">automatic</property> |
256 | + <child> |
257 | + <object class="GtkTreeView" id="contentq_view"> |
258 | + <property name="visible">True</property> |
259 | + <property name="sensitive">False</property> |
260 | + <property name="can_focus">True</property> |
261 | + <property name="model">contentq_store</property> |
262 | + <property name="headers_clickable">False</property> |
263 | + <property name="rules_hint">True</property> |
264 | + <property name="search_column">0</property> |
265 | + <property name="enable_grid_lines">both</property> |
266 | + <property name="enable_tree_lines">True</property> |
267 | + <child> |
268 | + <object class="GtkTreeViewColumn" id="contentq_operation"> |
269 | + <property name="title">Operation</property> |
270 | + <property name="expand">True</property> |
271 | + <child> |
272 | + <object class="GtkCellRendererText" id="cellrenderertext5"/> |
273 | + <attributes> |
274 | + <attribute name="text">0</attribute> |
275 | + </attributes> |
276 | + </child> |
277 | + </object> |
278 | + </child> |
279 | + <child> |
280 | + <object class="GtkTreeViewColumn" id="contentq_path"> |
281 | + <property name="title">Path</property> |
282 | + <property name="expand">True</property> |
283 | + <child> |
284 | + <object class="GtkCellRendererText" id="cellrenderertext6"/> |
285 | + <attributes> |
286 | + <attribute name="text">1</attribute> |
287 | + </attributes> |
288 | + </child> |
289 | + </object> |
290 | + </child> |
291 | + <child> |
292 | + <object class="GtkTreeViewColumn" id="contentq_node"> |
293 | + <property name="title">Node</property> |
294 | + <property name="expand">True</property> |
295 | + <child> |
296 | + <object class="GtkCellRendererText" id="cellrenderertext7"/> |
297 | + <attributes> |
298 | + <attribute name="text">2</attribute> |
299 | + </attributes> |
300 | + </child> |
301 | + </object> |
302 | + </child> |
303 | + <child> |
304 | + <object class="GtkTreeViewColumn" id="contentq_share"> |
305 | + <property name="title">Share</property> |
306 | + <property name="expand">True</property> |
307 | + <child> |
308 | + <object class="GtkCellRendererText" id="cellrenderertext8"/> |
309 | + <attributes> |
310 | + <attribute name="text">3</attribute> |
311 | + </attributes> |
312 | + </child> |
313 | + </object> |
314 | </child> |
315 | </object> |
316 | </child> |
317 | </object> |
318 | + <packing> |
319 | + <property name="position">1</property> |
320 | + </packing> |
321 | </child> |
322 | </object> |
323 | <packing> |
324 | - <property name="resize">False</property> |
325 | + <property name="resize">True</property> |
326 | <property name="shrink">True</property> |
327 | </packing> |
328 | </child> |
329 | |
330 | === modified file 'magicicada/__init__.py' |
331 | --- magicicada/__init__.py 2010-05-23 23:26:22 +0000 |
332 | +++ magicicada/__init__.py 2010-05-24 19:21:27 +0000 |
333 | @@ -171,7 +171,8 @@ |
334 | self._activate_indicator(self.is_online, sensitive=False) |
335 | |
336 | cs = self.sd.current_state |
337 | - self.on_status_changed(cs.name, cs.description) |
338 | + self.on_status_changed(name=cs.name, description=cs.description, |
339 | + queues=cs.queues, connection=cs.connection) |
340 | self.on_meta_queue_changed(self.sd.meta_queue) |
341 | self.on_content_queue_changed(self.sd.content_queue) |
342 | |
343 | @@ -206,7 +207,7 @@ |
344 | is_error=False, is_connected=True, is_online=True, |
345 | queues=None, connection=None): |
346 | """Callback'ed when the SD status changed.""" |
347 | - values = (v for v in (name, description, connection) if v) |
348 | + values = (v for v in (name, description, queues, connection) if v) |
349 | text = self.STATUS_JOINER.join(values) |
350 | if not (text or self.sd.current_state.is_started): |
351 | text = self.STATUS['initial'] |
352 | @@ -265,4 +266,5 @@ |
353 | self.on_content_queue_changed(self.sd.content_queue) |
354 | self.on_status_changed(name=current_state.name, |
355 | description=current_state.description, |
356 | + queues=current_state.queues, |
357 | connection=current_state.connection) |
358 | |
359 | === modified file 'magicicada/tests/test_magicicada.py' |
360 | --- magicicada/tests/test_magicicada.py 2010-05-23 23:26:22 +0000 |
361 | +++ magicicada/tests/test_magicicada.py 2010-05-24 19:21:27 +0000 |
362 | @@ -18,6 +18,8 @@ |
363 | |
364 | """Tests for magicicada.""" |
365 | |
366 | +from functools import wraps |
367 | + |
368 | import pango |
369 | |
370 | from twisted.trial.unittest import TestCase |
371 | @@ -58,7 +60,7 @@ |
372 | """Init.""" |
373 | self.ui = MagicicadaUI(syncdaemon_class=FakedSyncdaemon) |
374 | self._called = False |
375 | - self.set_called = lambda *_: setattr(self, '_called', True) |
376 | + self.set_called = lambda *args, **kwargs: setattr(self, '_called', True) |
377 | |
378 | def tearDown(self): |
379 | """Cleanup.""" |
380 | @@ -245,6 +247,16 @@ |
381 | self.assertTrue(self.ui.main_window.get_property('visible'), msg) |
382 | |
383 | |
384 | +def skip_abstract_class(test): |
385 | + """If 'test' belongs to an abstract class, don't run it.""" |
386 | + @wraps(test) |
387 | + def inner(klass): |
388 | + """Execute 'test' only if not in an abstract class.""" |
389 | + if klass.queue is not None: |
390 | + test(klass) |
391 | + return inner |
392 | + |
393 | + |
394 | class _MagicicadaUIQueueTestCase(MagicicadaUITestCase): |
395 | """Abstratc UI test cases for queue tree views.""" |
396 | |
397 | @@ -253,6 +265,8 @@ |
398 | def setUp(self): |
399 | """Init.""" |
400 | super(_MagicicadaUIQueueTestCase, self).setUp() |
401 | + if self.queue is None: |
402 | + return |
403 | self.sd_changed = getattr(self.ui.sd, |
404 | '%s_queue_changed_callback' % self.queue) |
405 | self.ui_changed = getattr(self.ui, |
406 | @@ -289,11 +303,13 @@ |
407 | |
408 | tree_iter = queue_store.iter_next(tree_iter) |
409 | |
410 | + @skip_abstract_class |
411 | def test_callback_is_connected(self): |
412 | """Queue changed callback is connected.""" |
413 | self.assertEqual(self.sd_changed, self.ui_changed, |
414 | '%s queue callback must be set' % self.queue) |
415 | |
416 | + @skip_abstract_class |
417 | def test_model_is_binded(self): |
418 | """List store is binded.""" |
419 | actual = self.queue_view.get_model() |
420 | @@ -301,12 +317,14 @@ |
421 | self.assertEqual(self.queue_store, actual, |
422 | msg % (self.queue, self.queue_store)) |
423 | |
424 | + @skip_abstract_class |
425 | def test_on_queue_changed_updates_view(self): |
426 | """On queue changed the view is updated.""" |
427 | items = self.build_some_data() |
428 | self.sd_changed(items) |
429 | self.assert_queue_store_correct(self.queue_store, items) |
430 | |
431 | + @skip_abstract_class |
432 | def test_model_is_cleared_before_updating(self): |
433 | """The model is cleared before upadting with a new set of data.""" |
434 | items = self.build_some_data() |
435 | @@ -316,6 +334,7 @@ |
436 | self.sd_changed(items) |
437 | self.assertEqual(len(self.queue_store), len(items)) |
438 | |
439 | + @skip_abstract_class |
440 | def test_view_is_enabled_if_disabled_on_changed(self): |
441 | """The tree view is enabled on changed if it was disabled.""" |
442 | self.assertFalse(self.queue_view.is_sensitive(), |
443 | @@ -326,6 +345,7 @@ |
444 | self.assertTrue(self.queue_view.is_sensitive(), |
445 | 'Tree view must be enabled on changed.') |
446 | |
447 | + @skip_abstract_class |
448 | def test_update_is_correct_for_queue(self): |
449 | """Correctly updates the queue state.""" |
450 | data = self.build_some_data() |
451 | @@ -335,6 +355,7 @@ |
452 | |
453 | self.assert_queue_store_correct(self.queue_store, data) |
454 | |
455 | + @skip_abstract_class |
456 | def test_on_stopped_updates_queue(self): |
457 | """On SD stoppped, the UI updates the queue state.""" |
458 | cb = 'on_%s_queue_changed' % self.queue |
459 | @@ -359,14 +380,26 @@ |
460 | class MagicicadaUIStatusTestCase(MagicicadaUITestCase): |
461 | """UI test cases for the status label.""" |
462 | |
463 | + def setUp(self): |
464 | + """Init.""" |
465 | + super(MagicicadaUIStatusTestCase, self).setUp() |
466 | + name = 'TEST' |
467 | + description = 'the status for testing' |
468 | + connection = 'Funny funny connection' |
469 | + queues = 'The queues are hilarious' |
470 | + self.kwargs = dict(name=name, description=description, |
471 | + connection=connection, queues=queues) |
472 | + |
473 | def assert_status_label_correct(self, name=None, description=None, |
474 | - connection=None, expected=None): |
475 | + connection=None, queues=None, |
476 | + expected=None): |
477 | """Test that the status label is of the form name: description.""" |
478 | if expected is None: |
479 | assert name is not None |
480 | assert description is not None |
481 | assert connection is not None |
482 | - values = (name, description, connection) |
483 | + assert queues is not None |
484 | + values = (name, description, queues, connection) |
485 | expected = self.ui.STATUS_JOINER.join(values) |
486 | |
487 | actual = self.ui.status_label.get_text() |
488 | @@ -387,46 +420,31 @@ |
489 | |
490 | def test_on_status_changed_updates_status_label(self): |
491 | """On status changed, the status label is updated.""" |
492 | - name = 'TEST' |
493 | - description = 'the status for testing' |
494 | - connection = 'funny funny connection' |
495 | - kwargs = dict(name=name, description=description, connection=connection) |
496 | - |
497 | # usual case, all values are defined |
498 | - self.ui.on_status_changed(**kwargs) |
499 | - self.assert_status_label_correct(**kwargs) |
500 | + self.ui.on_status_changed(**self.kwargs) |
501 | + self.assert_status_label_correct(**self.kwargs) |
502 | |
503 | def test_on_status_changed_updates_status_label_even_on_weird_cases(self): |
504 | """On status changed, the status label is updated.""" |
505 | - name = 'TEST' |
506 | - description = 'the status for testing' |
507 | - connection = 'funny funny connection' |
508 | - kwargs = dict(name=name, description=description, connection=connection) |
509 | - |
510 | - keywords = ('name', 'description', 'connection') # need ordering |
511 | + keywords = ('name', 'description', 'queues', 'connection') # need order |
512 | for attr in keywords: |
513 | - old_value = kwargs[attr] |
514 | + old_value = self.kwargs[attr] |
515 | |
516 | # some weird cases: attr is '' or None |
517 | for value in ('', None): |
518 | - kwargs[attr] = value |
519 | - self.ui.on_status_changed(**kwargs) |
520 | - others = (kwargs[k] for k in keywords if k != attr) |
521 | + self.kwargs[attr] = value |
522 | + self.ui.on_status_changed(**self.kwargs) |
523 | + others = (self.kwargs[k] for k in keywords if k != attr) |
524 | expected = self.ui.STATUS_JOINER.join(others) |
525 | self.assert_status_label_correct(expected=expected) |
526 | |
527 | - kwargs[attr] = old_value |
528 | + self.kwargs[attr] = old_value |
529 | |
530 | def test_update_is_correct_for_status_label(self): |
531 | """Correctly updates the status label.""" |
532 | - name = 'TEST' |
533 | - description = 'the status for testing' |
534 | - connection = 'funny funny connection' |
535 | - kwargs = dict(name=name, description=description, connection=connection) |
536 | - self.ui.sd.current_state._set(**kwargs) |
537 | - |
538 | + self.ui.sd.current_state._set(**self.kwargs) |
539 | self.ui.update() |
540 | - self.assert_status_label_correct(**kwargs) |
541 | + self.assert_status_label_correct(**self.kwargs) |
542 | |
543 | def test_on_stopped_updates_status_label(self): |
544 | """On SD stoppped, the UI updates the status label.""" |
Like it!