Add coverage for bulk_id object exporting

This commit is contained in:
Cameron Yick
2017-10-22 19:40:06 -04:00
parent b6ad06aebc
commit 79ac76806a

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests for `tiingo` package.""" """Tests for `tiingo` package."""
import csv import csv
@@ -12,13 +11,11 @@ from tiingo.restclient import RestClientError
# TODO # TODO
# Add tests for # Add tests for
# Invalid API key # - Invalid API key
# Invalid ticker # - Invalid ticker
# Use unittest asserts rather than regular asserts # Use unittest asserts rather than regular asserts if applicable
# Wrap server errors with client side descriptive errors # Wrap server errors with client side descriptive errors
# Coerce startDate/endDate to string if they are passed in as datetime # Coerce startDate/endDate to string if they are passed in as datetime
# Use VCR.py to enable offline testing
# Expand test coverage
def test_client_repr(): def test_client_repr():
@@ -136,6 +133,7 @@ class TestNews(TestCase):
value = self._client.get_bulk_news() value = self._client.get_bulk_news()
assert value assert value
# Tests "object" formatting option
@vcr.use_cassette('tests/fixtures/news.yaml') @vcr.use_cassette('tests/fixtures/news.yaml')
def test_get_news_as_objects(self): def test_get_news_as_objects(self):
articles = self._client.get_news(fmt="object", **self.search_params) articles = self._client.get_news(fmt="object", **self.search_params)
@@ -143,6 +141,13 @@ class TestNews(TestCase):
for article in articles: # check if attribute access works for article in articles: # check if attribute access works
assert all(hasattr(article, key) for key in self.article_keys) assert all(hasattr(article, key) for key in self.article_keys)
@vcr.use_cassette('tests/fixtures/news_bulk_file_ids.yaml')
def test_get_news_bulk_ids_as_objects(self):
"""Fails because this API key lacks institutional license"""
with self.assertRaises(RestClientError):
value = self._client.get_bulk_news(fmt="object")
assert value
@vcr.use_cassette('tests/fixtures/news_bulk.yaml') @vcr.use_cassette('tests/fixtures/news_bulk.yaml')
def test_news_bulk_as_objects(self): def test_news_bulk_as_objects(self):
"""Fails because this API key lacks institutional license""" """Fails because this API key lacks institutional license"""