summaryrefslogtreecommitdiff
path: root/invest-applet/invest/test.py
diff options
context:
space:
mode:
authorPerberos <[email protected]>2011-11-14 18:24:48 -0300
committerPerberos <[email protected]>2011-11-14 18:24:48 -0300
commit312ba610a1e98fc656fb58178227d7d45a64494e (patch)
tree54a3c2b6084c80e63fb0526c6e7b8e01627acbd7 /invest-applet/invest/test.py
downloadmate-applets-312ba610a1e98fc656fb58178227d7d45a64494e.tar.bz2
mate-applets-312ba610a1e98fc656fb58178227d7d45a64494e.tar.xz
initial
Diffstat (limited to 'invest-applet/invest/test.py')
-rwxr-xr-xinvest-applet/invest/test.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/invest-applet/invest/test.py b/invest-applet/invest/test.py
new file mode 100755
index 00000000..aea5f5f3
--- /dev/null
+++ b/invest-applet/invest/test.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+
+import unittest
+from os.path import *
+import sys
+
+# Make sure we run the local version
+sys.path.insert(0, abspath(dirname(__file__) + "/.."))
+print sys.path
+
+import quotes
+import invest
+
+def null_function (*args):
+ pass
+
+class TestQuotes (unittest.TestCase):
+ def testQuoteUpdater_populate (self):
+ qu = quotes.QuoteUpdater (null_function, null_function)
+ 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}]}}
+ quote = { 'GOGO': { "ticker": 'GOGO', "trade": 386.91, "time": "10/3/2008", "date": "4.00pm", "variation": -3.58, "open": 397.14, "variation_pct": 10 }}
+ qu.populate (quote)
+ self.assertEqual (qu.quotes_valid, True)
+ # In response to bug 554425, try a stock that isn't in our database
+ quote = { "clearlyFake": { "ticker": "clearlyFake", "trade": 386.91, "time": "10/3/2008", "date": "4.00pm", "variation": -3.58, "open": 397.14, "variation_pct": 10 }}
+ qu.populate (quote)
+ self.assertEqual (qu.quotes_valid, False)
+
+if __name__ == '__main__':
+ unittest.main ()