Update get_news() to work when no sources are provided.

Currently, `sources=[]` by default, which will become "" once the
list is `joined` to form a csv string. The tiingo api appears to
interpret the empty string as "don't match any sources" instead of
"match all sources". This commit fixes the problem by setting
`sources` to `None` if the list is empty.

Adds unit test for empty new sources list.

Updates HISTORY.rst with note about bug fix.
This commit is contained in:
David Minnen
2021-01-06 22:28:30 -08:00
committed by DavidMinnen
parent f6ef473b0d
commit aed36edb65
5 changed files with 60 additions and 2 deletions

View File

@@ -183,6 +183,15 @@ class TestNews(TestCase):
for article in articles:
assert all(key in article for key in self.article_keys)
@vcr.use_cassette('tests/fixtures/news_empty_sources.yaml')
def test_get_news_empty_sources(self):
search_params = self.search_params.copy()
search_params['sources'] = []
articles = self._client.get_news(**search_params)
assert len(articles) == self.num_articles
for article in articles:
assert all(key in article for key in self.article_keys)
@vcr.use_cassette('tests/fixtures/news_bulk.yaml')
def test_get_news_bulk(self):
"""Fails because this API key lacks institutional license"""