mirror of
https://github.com/hongtaocai/googlefinance.git
synced 2025-02-25 18:55:20 -06:00
refactore code and tests
This commit is contained in:
parent
28e0fab588
commit
bbda3eaa54
@ -23,9 +23,9 @@ googleFinanceKeyToFullName = {
|
||||
|
||||
|
||||
def buildUrl(symbols):
|
||||
aux_symbols = filter(lambda value: value.strip() != "", symbols)
|
||||
if len(aux_symbols) != len(symbols):
|
||||
raise Exception("Does not input value empty.")
|
||||
aux_symbols = [s for s in symbols if s.strip() != ""]
|
||||
if len(aux_symbols) == 0 or len(aux_symbols) != len(symbols):
|
||||
raise Exception("Can not be blank.")
|
||||
# a deprecated but still active & correct api
|
||||
return 'http://finance.google.com/finance/info?client=ig&q={0}'.format(
|
||||
','.join(aux_symbols))
|
||||
|
@ -17,6 +17,8 @@ class TestQuotes(unittest.TestCase):
|
||||
self.assertEqual(quotes[1]["StockSymbol"], "BKS")
|
||||
|
||||
def test_empty(self):
|
||||
with self.assertRaises(Exception) as e:
|
||||
try:
|
||||
googlefinance.getQuotes("")
|
||||
self.assertTrue("Can not be blank." in str(e.exception))
|
||||
self.assertTrue(False)
|
||||
except Exception as e:
|
||||
self.assertTrue("Can not be blank." in str(e))
|
||||
|
Loading…
Reference in New Issue
Block a user