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