diff --git a/.travis.yml b/.travis.yml index ef770b0..2c59935 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,9 +9,9 @@ deploy: provider: pypi user: hydrosquall -install: +install: - python setup.py develop - - pip install -U pytest-cov codecov + - pip install -U pytest-cov codecov vcrpy # - pip install -U tox-travis pytest language: python @@ -23,12 +23,12 @@ python: - 2.7 # - 2.6 -script: - - export TIINGO_API_KEY=$TIINGO_API_KEY +script: + - export TIINGO_API_KEY=0000000000000000000000000000000000000000 - py.test --cov=./tiingo matrix: fast_finish: true -after_success: -- codecov \ No newline at end of file +after_success: +- codecov diff --git a/requirements_dev.txt b/requirements_dev.txt index 7b45fb2..860f19e 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -10,3 +10,4 @@ cryptography==2.0.3 PyYAML==3.12 pytest==3.2.2 pytest-runner==2.12.1 +vcrpy==1.11.1 diff --git a/setup.py b/setup.py index 7c3b8a7..71a43d3 100644 --- a/setup.py +++ b/setup.py @@ -34,6 +34,7 @@ setup_requirements = [ test_requirements = [ 'pytest', + 'vcrpy', ] # Metadata about the module diff --git a/tests/fixtures/invalid_url.yaml b/tests/fixtures/invalid_url.yaml new file mode 100644 index 0000000..9c33629 --- /dev/null +++ b/tests/fixtures/invalid_url.yaml @@ -0,0 +1,33 @@ +interactions: +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + User-Agent: [python-requests/2.18.4] + method: GET + uri: http://www.google.com/bing_is_great + response: + body: {string: "\n\n \n \n + \
404. That\u2019s an error.\n
The requested URL
+ /bing_is_great was not found on this server. That\u2019s
+ all we know.\n"}
+ headers:
+ Content-Length: ['1574']
+ Content-Type: [text/html; charset=UTF-8]
+ Date: ['Sun, 08 Oct 2017 10:13:15 GMT']
+ Referrer-Policy: [no-referrer]
+ status: {code: 404, message: Not Found}
+version: 1
diff --git a/tests/fixtures/list_stock_tickers.yaml b/tests/fixtures/list_stock_tickers.yaml
new file mode 100644
index 0000000..b9d8ffe
--- /dev/null
+++ b/tests/fixtures/list_stock_tickers.yaml
@@ -0,0 +1,34 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept: ['*/*']
+ Accept-Encoding: ['gzip, deflate']
+ Connection: [keep-alive]
+ User-Agent: [python-requests/2.18.4]
+ method: GET
+ uri: https://apimedia.tiingo.com/docs/tiingo/daily/supported_tickers.zip
+ response:
+ body:
+ string: !!binary |
+ UEsDBBQAAAAIANlmSEvFDDeNdAAAAJMAAAAVABwAc3VwcG9ydGVkX3RpY2tlcnMuY3N2VVQJAAP6
+ A9pZ+gPaWXV4CwABBPUBAAAEFAAAAG3KwQrCMAyA4fueJYG0iG7HYmEXcUr1AUoMOgbdSCO4t1dv
+ HoQf/stnI0+iIC9+5HIXyLWKXdZFYNGRZf9UlcIrVMtqMZuAlNv3TQinAxxDiuEMyWae4JoiuK4l
+ dP4TeHI7dIS0bfph6P9gT7RBatF1v/gNUEsBAh4DFAAAAAgA2WZIS8UMN410AAAAkwAAABUAGAAA
+ AAAAAQAAAICBAAAAAHN1cHBvcnRlZF90aWNrZXJzLmNzdlVUBQAD+gPaWXV4CwABBPUBAAAEFAAA
+ AFBLBQYAAAAAAQABAFsAAADDAAAAAAA=
+ headers:
+ Accept-Ranges: [bytes]
+ Age: ['820']
+ Connection: [keep-alive]
+ Content-Length: ['2709436']
+ Content-Type: [application/zip]
+ Date: ['Sun, 08 Oct 2017 10:17:38 GMT']
+ ETag: ['"aa6b2d0623735374b5c471305911fbac"']
+ Last-Modified: ['Sat, 07 Oct 2017 23:28:33 GMT']
+ Server: [AmazonS3]
+ Via: [1.1 5d4ff22febf83d261f03aa068f5bdc04.cloudfront.net (CloudFront)]
+ X-Amz-Cf-Id: [Eo3QEjB2WELpsXJhXHqylxkoU2G3DVFXCa6Ka7d0sDhOh2JG3HA08w==]
+ X-Cache: [Hit from cloudfront]
+ status: {code: 200, message: OK}
+version: 1
diff --git a/tests/fixtures/news.yaml b/tests/fixtures/news.yaml
new file mode 100644
index 0000000..e1d6464
--- /dev/null
+++ b/tests/fixtures/news.yaml
@@ -0,0 +1,35 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept: ['*/*']
+ Accept-Encoding: ['gzip, deflate']
+ Authorization: [Token 0000000000000000000000000000000000000000]
+ Connection: [keep-alive]
+ Content-Type: [application/json]
+ User-Agent: [tiingo-python-client 0.3.2]
+ method: GET
+ uri: https://api.tiingo.com/tiingo/news?limit=1&offset=0&sortBy=publishedDate&tickers=aapl&tickers=googl&sources=washingtonpost.com&sources=altcointoday.com&tags=Technology&tags=Bitcoin&startDate=2016-01-01&endDate=2017-08-31
+ response:
+ body: {string: '[{
+ "publishedDate": "2016-01-11T23:13:00Z",
+ "title": "Tech giants may be stronger than you think",
+ "url": "http://www.cnbc.com/2016/01/11/tech-giants-may-be-stronger-than-you-think.html",
+ "description": "Technology companies could soon rebound from the dip that China’s markets caused them as earnings season approaches, according to experts.",
+ "source": "cnbc.com",
+ "sourceDate": "2016-01-12T21:07:28.073309+00:00",
+ "tickers": ["googl", "aapl", "amzn", "msft", "nflx", "fb"],
+ "tags": ["Internet", "Investing", "Business", "Economic Reports", "Finance", "Economics", "Computing", "Asia", "Gdp", "Wireless", "China", "Technology", "Places", "Tiingo Top", "Information Technology", "Consumer Discretionary"],
+ "crawlDate": "2016-01-12T21:07:28.073309+00:00",
+ "id": 0
+}]'}
+ headers:
+ Allow: ['GET, HEAD, OPTIONS']
+ Content-Length: ['62']
+ Content-Type: [application/json]
+ Date: ['Sun, 08 Oct 2017 10:17:17 GMT']
+ Server: [nginx/1.10.1]
+ Vary: ['Accept, Cookie']
+ X-Frame-Options: [SAMEORIGIN]
+ status: {code: 200, message: OK}
+version: 1
diff --git a/tests/fixtures/news_bulk.yaml b/tests/fixtures/news_bulk.yaml
new file mode 100644
index 0000000..7f964a0
--- /dev/null
+++ b/tests/fixtures/news_bulk.yaml
@@ -0,0 +1,24 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept: ['*/*']
+ Accept-Encoding: ['gzip, deflate']
+ Authorization: [Token 0000000000000000000000000000000000000000]
+ Connection: [keep-alive]
+ Content-Type: [application/json]
+ User-Agent: [tiingo-python-client 0.3.2]
+ method: GET
+ uri: https://api.tiingo.com/tiingo/news/bulk_download/1
+ response:
+ body: {string: '{"detail":"You do not have permission to access the News API"}'}
+ headers:
+ Allow: ['GET, HEAD, OPTIONS']
+ Content-Length: ['62']
+ Content-Type: [application/json]
+ Date: ['Sun, 08 Oct 2017 10:21:32 GMT']
+ Server: [nginx/1.10.1]
+ Vary: [Cookie]
+ X-Frame-Options: [SAMEORIGIN]
+ status: {code: 403, message: Forbidden}
+version: 1
diff --git a/tests/fixtures/news_bulk_file_ids.yaml b/tests/fixtures/news_bulk_file_ids.yaml
new file mode 100644
index 0000000..6f324f9
--- /dev/null
+++ b/tests/fixtures/news_bulk_file_ids.yaml
@@ -0,0 +1,24 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept: ['*/*']
+ Accept-Encoding: ['gzip, deflate']
+ Authorization: [Token 0000000000000000000000000000000000000000]
+ Connection: [keep-alive]
+ Content-Type: [application/json]
+ User-Agent: [tiingo-python-client 0.3.2]
+ method: GET
+ uri: https://api.tiingo.com/tiingo/news/bulk_download
+ response:
+ body: {string: '{"detail":"You do not have permission to access the News API"}'}
+ headers:
+ Allow: ['GET, HEAD, OPTIONS']
+ Content-Length: ['62']
+ Content-Type: [application/json]
+ Date: ['Sun, 08 Oct 2017 10:21:33 GMT']
+ Server: [nginx/1.10.1]
+ Vary: [Cookie]
+ X-Frame-Options: [SAMEORIGIN]
+ status: {code: 403, message: Forbidden}
+version: 1
diff --git a/tests/fixtures/ticker_metadata.yaml b/tests/fixtures/ticker_metadata.yaml
new file mode 100644
index 0000000..6db7477
--- /dev/null
+++ b/tests/fixtures/ticker_metadata.yaml
@@ -0,0 +1,36 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept: ['*/*']
+ Accept-Encoding: ['gzip, deflate']
+ Authorization: [Token 0000000000000000000000000000000000000000]
+ Connection: [keep-alive]
+ Content-Type: [application/json]
+ User-Agent: [tiingo-python-client 0.3.2]
+ method: GET
+ uri: https://api.tiingo.com/tiingo/daily/GOOGL
+ response:
+ body: {string: '{"endDate":"2017-10-06","startDate":"2004-08-19","exchangeCode":"NASDAQ","name":"Alphabet
+ Inc.(\"Google\") - Class A","description":"Google Inc. (Google) is a global
+ technology company. The Company''s business is primarily focused around key
+ areas, such as search, advertising, operating systems and platforms, enterprise
+ and hardware products. The Company generates revenue primarily by delivering
+ online advertising. The Company also generates revenues from Motorola by selling
+ hardware products. The Company provides its products and services in more
+ than 100 languages and in more than 50 countries, regions, and territories.
+ Effective May 16, 2014, Google Inc acquired Quest Visual Inc. Effective May
+ 20, 2014, Google Inc acquired Enterproid Inc, doing business as Divide. In
+ June 2014, Google Inc acquired mDialog Corp. Effective June 25, 2014, Google
+ Inc acquired Appurify Inc, a San Francisco-based developer of mobile bugging
+ application software.","ticker":"GOOGL"}'}
+ headers:
+ Allow: ['GET, HEAD, OPTIONS']
+ Content-Length: ['974']
+ Content-Type: [application/json]
+ Date: ['Sun, 08 Oct 2017 10:17:19 GMT']
+ Server: [nginx/1.10.1]
+ Vary: ['Accept, Cookie']
+ X-Frame-Options: [SAMEORIGIN]
+ status: {code: 200, message: OK}
+version: 1
diff --git a/tests/fixtures/ticker_price.yaml b/tests/fixtures/ticker_price.yaml
new file mode 100644
index 0000000..a69a2ff
--- /dev/null
+++ b/tests/fixtures/ticker_price.yaml
@@ -0,0 +1,24 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept: ['*/*']
+ Accept-Encoding: ['gzip, deflate']
+ Authorization: [Token 0000000000000000000000000000000000000000]
+ Connection: [keep-alive]
+ Content-Type: [application/json]
+ User-Agent: [tiingo-python-client 0.3.2]
+ method: GET
+ uri: https://api.tiingo.com/tiingo/daily/GOOGL/prices?format=json&frequency=daily
+ response:
+ body: {string: '[{"adjClose":993.64,"adjHigh":994.26,"adjLow":978.51,"adjOpen":980.0,"adjVolume":1490744,"close":993.64,"date":"2017-10-06T00:00:00+00:00","divCash":0.0,"high":994.26,"low":978.51,"open":980.0,"splitFactor":1.0,"volume":1490744}]'}
+ headers:
+ Allow: ['GET, HEAD, OPTIONS']
+ Content-Length: ['229']
+ Content-Type: [application/json]
+ Date: ['Sun, 08 Oct 2017 10:17:18 GMT']
+ Server: [nginx/1.10.1]
+ Vary: ['Accept, Cookie']
+ X-Frame-Options: [SAMEORIGIN]
+ status: {code: 200, message: OK}
+version: 1
diff --git a/tests/fixtures/ticker_price_with_date.yaml b/tests/fixtures/ticker_price_with_date.yaml
new file mode 100644
index 0000000..0af3fef
--- /dev/null
+++ b/tests/fixtures/ticker_price_with_date.yaml
@@ -0,0 +1,24 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept: ['*/*']
+ Accept-Encoding: ['gzip, deflate']
+ Authorization: [Token 0000000000000000000000000000000000000000]
+ Connection: [keep-alive]
+ Content-Type: [application/json]
+ User-Agent: [tiingo-python-client 0.3.2]
+ method: GET
+ uri: https://api.tiingo.com/tiingo/daily/GOOGL/prices?format=json&frequency=daily&startDate=2015-01-01&endDate=2015-01-05
+ response:
+ body: {string: '[{"date":"2015-01-02T00:00:00.000Z","close":529.55,"high":535.8,"low":527.88,"open":532.6,"volume":1327870,"adjClose":529.55,"adjHigh":535.8,"adjLow":527.88,"adjOpen":532.6,"adjVolume":1327870,"divCash":0.0,"splitFactor":1.0},{"date":"2015-01-05T00:00:00.000Z","close":519.46,"high":527.9899,"low":517.75,"open":527.15,"volume":2059119,"adjClose":519.46,"adjHigh":527.9899,"adjLow":517.75,"adjOpen":527.15,"adjVolume":2059119,"divCash":0.0,"splitFactor":1.0}]'}
+ headers:
+ Allow: ['GET, HEAD, OPTIONS']
+ Content-Length: ['459']
+ Content-Type: [application/json]
+ Date: ['Sun, 08 Oct 2017 10:17:25 GMT']
+ Server: [nginx/1.10.1]
+ Vary: ['Accept, Cookie']
+ X-Frame-Options: [SAMEORIGIN]
+ status: {code: 200, message: OK}
+version: 1
diff --git a/tests/fixtures/ticker_price_with_date_csv.yaml b/tests/fixtures/ticker_price_with_date_csv.yaml
new file mode 100644
index 0000000..b91d0a6
--- /dev/null
+++ b/tests/fixtures/ticker_price_with_date_csv.yaml
@@ -0,0 +1,30 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept: ['*/*']
+ Accept-Encoding: ['gzip, deflate']
+ Authorization: [Token 0000000000000000000000000000000000000000]
+ Connection: [keep-alive]
+ Content-Type: [application/json]
+ User-Agent: [tiingo-python-client 0.3.2]
+ method: GET
+ uri: https://api.tiingo.com/tiingo/daily/GOOGL/prices?format=csv&frequency=daily&startDate=2015-01-01&endDate=2015-01-05
+ response:
+ body: {string: 'date,close,high,low,open,volume,adjClose,adjHigh,adjLow,adjOpen,adjVolume,divCash,splitFactor
+
+ 2015-01-02,529.55,535.8,527.88,532.6,1327870,529.55,535.8,527.88,532.6,1327870,0.0,1.0
+
+ 2015-01-05,519.46,527.9899,517.75,527.15,2059119,519.46,527.9899,517.75,527.15,2059119,0.0,1.0
+
+'}
+ headers:
+ Allow: ['GET, HEAD, OPTIONS']
+ Content-Length: ['276']
+ Content-Type: [text/csv]
+ Date: ['Sun, 08 Oct 2017 10:17:24 GMT']
+ Server: [nginx/1.10.1]
+ Vary: ['Accept, Cookie']
+ X-Frame-Options: [SAMEORIGIN]
+ status: {code: 200, message: OK}
+version: 1
diff --git a/tests/fixtures/valid_url.yaml b/tests/fixtures/valid_url.yaml
new file mode 100644
index 0000000..ae1b21c
--- /dev/null
+++ b/tests/fixtures/valid_url.yaml
@@ -0,0 +1,145 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept: ['*/*']
+ Accept-Encoding: ['gzip, deflate']
+ Connection: [keep-alive]
+ User-Agent: [python-requests/2.18.4]
+ method: GET
+ uri: http://www.google.com/
+ response:
+ body: {string: "