Skip to content

Commit

Permalink
Update test case
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmysitu committed Nov 2, 2023
1 parent ef613d8 commit a7d8e72
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
6 changes: 3 additions & 3 deletions msfinance/stocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def get_xnas_tickers(self):
List of ticker names in NASDAQ
'''

exchange = 'NASDAQ'
exchange = 'nasdaq'
return self._get_us_exchange_tickers(exchange)

def get_xnys_tickers(self):
Expand All @@ -486,7 +486,7 @@ def get_xnys_tickers(self):
List of ticker names in NYSE
'''

exchange = 'NYSE'
exchange = 'nyse'
return self._get_us_exchange_tickers(exchange)

def get_xase_tickers(self):
Expand All @@ -497,7 +497,7 @@ def get_xase_tickers(self):
List of ticker names in AMEX
'''

exchange = 'AMEX'
exchange = 'amex'
return self._get_us_exchange_tickers(exchange)


Expand Down
25 changes: 23 additions & 2 deletions tests/test_stocks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/python3 -u

import sqlite3
from msfinance import stocks
import os
import time
Expand All @@ -11,17 +12,19 @@

def test_stocks():
proxy = 'socks5://127.0.0.1:1088'
session='/tmp/msfinance/msf.sql3'


if 'true' == os.getenv('GITHUB_ACTIONS'):
stock = stocks.Stock(
debug=False,
session='/tmp/msfinance/msf.sql3',
session=session,
proxy=None,
)
else:
stock = stocks.Stock(
debug=False,
session='/tmp/msfinance/msf.sql3',
session=session,
proxy=proxy,
)

Expand All @@ -45,3 +48,21 @@ def test_stocks():
stock.get_cash_flow('aapl', 'xnas')


db = sqlite3.connect(session)

for exchange in ['nasdaq', 'nyse', 'amex']:
query = f"SELECT * FROM us_exchange_{exchange}_tickers"
df = pd.read_sql_query(query, db)
assert df is not None, f"{query} is not found in database"

assert 'AAPL' in sp500_tickers

for statement in ['income_statement', 'balance_sheet', 'cash_flow']:
query = f"SELECT * FROM aapl_xnas_{statement}_annual_as_originally_reported"
df = pd.read_sql_query(query, db)
assert df is not None, f"{query} is not found in database"

for statistics in ['growth', 'operating_and_efficiency', 'financial_health','cash_flow']:
query = f"SELECT * FROM aapl_xnas_{statistics}"
df = pd.read_sql_query(query, db)
assert df is not None, f"{query} is not found in database"

0 comments on commit a7d8e72

Please sign in to comment.