~ubuntu-branches/ubuntu/vivid/mate-applets/vivid-proposed

« back to all changes in this revision

Viewing changes to invest-applet/invest/test.py

  • Committer: Package Import Robot
  • Author(s): Mike Gabriel
  • Date: 2014-04-21 13:57:07 UTC
  • Revision ID: package-import@ubuntu.com-20140421135707-hh4arlnzglq9xxfo
Tags: upstream-1.8.0+dfsg1
ImportĀ upstreamĀ versionĀ 1.8.0+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
import unittest
 
4
from os.path import *
 
5
import sys
 
6
 
 
7
# Make sure we run the local version
 
8
sys.path.insert(0, abspath(dirname(__file__) + "/.."))
 
9
print sys.path
 
10
 
 
11
import quotes
 
12
import mate_invest
 
13
 
 
14
def null_function (*args):
 
15
    pass
 
16
 
 
17
class TestQuotes (unittest.TestCase):
 
18
    def testQuoteUpdater_populate (self):
 
19
        qu = quotes.QuoteUpdater (null_function, null_function)
 
20
        mate_invest.STOCKS = {'GOGO': {'label': "Google Inc.", 'purchases': [{'amount' : 1, 'comission' : 0.0, 'bought': 0.0}]}, 'JAVA': {'label':"Sun Microsystems Inc.", 'purchases': [{'amount' : 1, 'comission' : 0.0, 'bought': 0.0}]}}
 
21
        quote = { 'GOGO': { "ticker": 'GOGO', "trade": 386.91, "time": "10/3/2008", "date": "4.00pm", "variation": -3.58, "open": 397.14, "variation_pct": 10 }}
 
22
        qu.populate (quote)
 
23
        self.assertEqual (qu.quotes_valid, True)
 
24
        # In response to bug 554425, try a stock that isn't in our database
 
25
        quote = { "clearlyFake": { "ticker": "clearlyFake", "trade": 386.91, "time": "10/3/2008", "date": "4.00pm", "variation": -3.58, "open": 397.14, "variation_pct": 10 }}
 
26
        qu.populate (quote)
 
27
        self.assertEqual (qu.quotes_valid, False)
 
28
 
 
29
if __name__ == '__main__':
 
30
    unittest.main ()