~ubuntuone-hackers/ubuntu-rest-scopes/trunk

« back to all changes in this revision

Viewing changes to src/scopes/tests/test_yahoofinance.py

  • Committer: Facundo Batista
  • Date: 2016-06-07 14:01:21 UTC
  • mfrom: (508.2.9 ubuntu-rest-scopes)
  • mto: This revision was merged to the branch mainline in revision 527.
  • Revision ID: facundo@taniquetil.com.ar-20160607140121-id1tzsnaa1lwtrb8
MergedĀ lp:~jamesh/ubuntu-rest-scopes/multi-column

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf8 -*-
 
1
# -*- coding: utf-8 -*-
2
2
 
3
3
# Copyright 2014-2015 Canonical
4
4
# All Rights Reserved
308
308
        app = yahoofinance.App(CONFIG)
309
309
        response = list(app.preview(result=result, locale='C'))
310
310
 
 
311
        self.assertTrue('columns' in response[0])
 
312
 
311
313
        # check the graph
312
314
        should = dict(widget={
313
315
            'id': 'art',
314
316
            'type': 'image',
315
317
            'source': 'http://chart.finance.yahoo.com/z?s=UBNT&z=s&t=7d',
316
318
        })
317
 
        self.assertEqual(response[0], should)
 
319
        self.assertEqual(response[1], should)
318
320
 
319
321
        # check the header
320
322
        should = dict(widget={
323
325
            'subtitle': 'UBNT - TUX',
324
326
            'title': 'Ubuntu Corp.'
325
327
        })
326
 
        self.assertEqual(response[1], should)
 
328
        self.assertEqual(response[2], should)
327
329
 
328
330
        # check the text
329
331
        should = dict(widget={
331
333
            'type': 'text',
332
334
            'text': 'Price: 1337\nChange: +1\n% Change: +14.10%',
333
335
        })
334
 
        self.assertEqual(response[2], should)
 
336
        self.assertEqual(response[3], should)
335
337
 
336
338
        # check the buttons
337
339
        should = dict(widget={
341
343
                         'label': 'Yahoo! Finance',
342
344
                         'uri': 'http://finance.yahoo.com/q?s=UBNT'}],
343
345
        })
344
 
        self.assertEqual(response[3], should)
 
346
        self.assertEqual(response[4], should)
345
347
 
346
348
    def test_news_preview(self):
347
349
        # fake a previous news result
356
358
        app = yahoofinance.App(CONFIG)
357
359
        response = list(app.preview(result=result, locale='C'))
358
360
 
 
361
        self.assertTrue('columns' in response[0])
 
362
 
359
363
        # check the header
360
364
        should = dict(widget={
361
365
            'id': 'header',
363
367
            'subtitle': 'news date',
364
368
            'title': 'news title'
365
369
        })
366
 
        self.assertEqual(response[0], should)
 
370
        self.assertEqual(response[1], should)
367
371
 
368
372
        # check the buttons
369
373
        should = dict(widget={
373
377
                         'label': 'Yahoo! Finance',
374
378
                         'uri': 'news uri'}],
375
379
        })
376
 
        self.assertEqual(response[1], should)
 
380
        self.assertEqual(response[2], should)
377
381
 
378
382
        # check the summary
379
383
        should = dict(widget={
381
385
            'type': 'text',
382
386
            'text': 'news summary',
383
387
        })
384
 
        self.assertEqual(response[2], should)
 
388
        self.assertEqual(response[3], should)
385
389
 
386
390
    def test_get_quotes_ok(self):
387
391
        app = yahoofinance.App(CONFIG)