Skip to content

Commit

Permalink
fixing company_news_rh() function to comply with API update
Browse files Browse the repository at this point in the history
  • Loading branch information
lockefox committed Aug 16, 2017
1 parent a9e6d3f commit 96d72f6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
7 changes: 5 additions & 2 deletions tests/schemas/stocks/rh_news.schema
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
"summary": {"type":"string"},
"api_source": {"type":"string", "enum":["yahoo_finance", "seeking_alpha"]},
"updated_at": {"type":"string"},
"instrument": {"type":"string", "format":"uri"}
"instrument": {"type":"string", "format":"uri"},
"num_clicks": {"type":"integer"},
"uuid": {"type":"null"}
},
"requires": [
"url", "title", "source", "published_at", "author",
"summary", "api_source", "updated_at", "instrument"],
"summary", "api_source", "updated_at", "instrument",
"num_clicks", "uuid"],
"additionalProperties": false
}
17 changes: 7 additions & 10 deletions tests/test_stocks_news.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ class TestCompanyNewsRobinhood:
"""validate behavior for news.fetch_company_news_rh()"""
good_ticker = helpers.CONFIG.get('STOCKS', 'good_ticker')
bad_ticker = helpers.CONFIG.get('STOCKS', 'bad_ticker')
expected_news_cols = [
'api_source', 'author', 'instrument', 'num_clicks', 'published_at',
'source', 'summary', 'title', 'updated_at', 'url', 'uuid'
]

@pytest.mark.long
def test_default_happypath(self):
Expand Down Expand Up @@ -225,11 +229,7 @@ def test_company_news_rh_happypath(self):

assert isinstance(all_news_df, pandas.DataFrame)

expected_cols = [
'api_source', 'author', 'instrument', 'published_at',
'source', 'summary', 'title', 'updated_at', 'url'
]
assert list(all_news_df.columns.values) == expected_cols
assert list(all_news_df.columns.values) == self.expected_news_cols

@pytest.mark.long
def test_vader_application(self):
Expand All @@ -239,10 +239,7 @@ def test_vader_application(self):

graded_news = utils.vader_sentiment(all_news_df, 'title')

expected_cols = [
'api_source', 'author', 'instrument', 'published_at',
'source', 'summary', 'title', 'updated_at', 'url',
'neu', 'pos', 'compound', 'neg'
]
expected_cols = self.expected_news_cols
expected_cols.extend(['neu', 'pos', 'compound', 'neg'])

assert list(graded_news.columns.values) == expected_cols

0 comments on commit 96d72f6

Please sign in to comment.