mirror of
https://github.com/hydrosquall/tiingo-python.git
synced 2026-01-31 16:44:20 +01:00
Patch testing for /funds endpoint
This commit is contained in:
@@ -30,10 +30,9 @@ class TestRestClient(TestCase):
|
||||
|
||||
# Test 404 error
|
||||
def test_invalid_url(self):
|
||||
with self.assertRaisesRegexp(RestClientError, "404") as context:
|
||||
with self.assertRaisesRegexp(RestClientError, "404"):
|
||||
# Should return 404 error
|
||||
self._client._request('GET', "bing_is_great")
|
||||
print(context)
|
||||
|
||||
# Todo: try using an invalid HTTP method (i.e. SNAG) and catch the error
|
||||
|
||||
@@ -61,7 +60,6 @@ class TestRestClientWithSession(TestCase):
|
||||
|
||||
# Test 404 error
|
||||
def test_invalid_url(self):
|
||||
with self.assertRaisesRegexp(RestClientError, "404") as context:
|
||||
with self.assertRaisesRegexp(RestClientError, "404"):
|
||||
# Should return 404 error
|
||||
self._client._request('GET', "bing_is_great")
|
||||
print(context)
|
||||
|
||||
@@ -6,6 +6,7 @@ import csv
|
||||
import pytest
|
||||
from unittest import TestCase
|
||||
from tiingo import TiingoClient
|
||||
from tiingo.restclient import RestClientError
|
||||
|
||||
|
||||
# TODO
|
||||
@@ -87,15 +88,25 @@ class TestTickerPrices(TestCase):
|
||||
# FUND ENDPOINTS
|
||||
# tiingo/funds
|
||||
# Try to get a working API key from Tiingo development for testing purposes
|
||||
@pytest.mark.skip(reason="My API key doesn't have access to mutual funds API")
|
||||
|
||||
class TestMutualFunds(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self._client = TiingoClient()
|
||||
self._metadata_response = self._client.get_fund_metrics('VFINX')
|
||||
self._metrics_response = \
|
||||
self._client.get_fund_metrics('VFINX',
|
||||
startDate="2012-1-1",
|
||||
endDate="2016-1-1")
|
||||
|
||||
@pytest.mark.skip(reason="My API key doesn't have access to mutual funds API")
|
||||
def test_fund_metadata(self, fund_metadata_response):
|
||||
"""Refactor this with python data schemavalidation"""
|
||||
assert fund_metadata_response.get('ticker') == "vfinx"
|
||||
assert fund_metadata_response.get("shareClass", startDate="2012-1-1",
|
||||
endDate="2016-1-1")
|
||||
|
||||
@pytest.mark.skip(reason="My API key doesn't have access to mutual funds API")
|
||||
def test_fund_metrics(self, fund_metrics_response):
|
||||
"""Test Fund Level Metrics"""
|
||||
assert len(fund_metrics_response) > 0
|
||||
@@ -112,6 +123,11 @@ class TestNews(TestCase):
|
||||
def test_get_news_articles(self):
|
||||
"""Rewrite when method is implemented
|
||||
"""
|
||||
with self.assertRaises(NotImplementedError) as context:
|
||||
self.get_news()
|
||||
print(context)
|
||||
with self.assertRaises(NotImplementedError):
|
||||
self._client.get_news()
|
||||
|
||||
def test_get_news_bulk(self):
|
||||
"""Will fail because this API key lacks institutional license"""
|
||||
with self.assertRaises(RestClientError):
|
||||
value = self._client.get_bulk_news(file_id="1")
|
||||
assert value
|
||||
|
||||
Reference in New Issue
Block a user