Skip to content

Commit

Permalink
Merge pull request #98 from jackmoody11/develop
Browse files Browse the repository at this point in the history
Add more coverage for tests
  • Loading branch information
jackmoody11 committed May 15, 2019
2 parents 9c3965f + a1f8479 commit 629d168
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Expand Up @@ -6,6 +6,7 @@ source = codecov
exclude_lines =
pragma: no cover
def __repr__
def __str__
if .debug:
raise NotImplementedError
if __name__ == .__main__.:
Expand Down
3 changes: 3 additions & 0 deletions README.rst
Expand Up @@ -15,6 +15,9 @@ Stock Score
.. image:: https://img.shields.io/github/license/mashape/apistatus.svg?style=popout
:target: https://github.com/jackmoody11/stockscore/blob/master/LICENSE

.. image:: https://badge.fury.io/py/stockscore.svg
:target: https://badge.fury.io/py/stockscore

Stock Score is a python script to score stocks based on specified
criteria. The goal of this project is to provide a stock screening
system for various types of stock classifications (growth, momentum, value, etc.).
Expand Down
14 changes: 8 additions & 6 deletions stockscore/data.py
Expand Up @@ -52,7 +52,7 @@ def __init__(self, stocks=None):
self.dividends = None

def __str__(self):
return ('Stocks: {stocks}'
return ('Stocks: {stocks},'
'Batches: {batches}').format(**self.__dict__)

def __repr__(self):
Expand Down Expand Up @@ -144,11 +144,13 @@ def get_volume(self):
pandas.DataFrame: pandas.DataFrame with volumes of symbols
"""
with Pool() as pool:
self.volume = pd.concat(
pool.starmap(self.iex_get_volume, [
[batch] for batch in self.batches])
)
dfs = map(self.iex_get_volume, [[batch] for batch in self.batches])
self.volume = pd.concat(dfs)
# with Pool() as pool:
# self.volume = pd.concat(
# pool.starmap(self.iex_get_volume, [
# [batch] for batch in self.batches])
# )

@staticmethod
def get_responses(payloads):
Expand Down
8 changes: 8 additions & 0 deletions stockscore/tests/test_data.py
Expand Up @@ -27,6 +27,11 @@ def test_stocks_set():
raise AssertionError("Stocks(symbols).stocks should equal symbols")


def test_stocks_requires_symbols():
with pytest.raises(Exception):
Stocks()


@pytest.mark.slow
def test_get_stats():
stocks.get_stats()
Expand Down Expand Up @@ -118,3 +123,6 @@ def test_return_top():
raise AssertionError("return_top should return pandas DataFrame.")
if not top.index[0] == "FB":
raise AssertionError("Top stock is not expected stock")
top_all = return_top(tscores, "Score")
if not len(top_all) == len(tscores):
raise AssertionError("All scores should be returned if no number is specified.")

0 comments on commit 629d168

Please sign in to comment.