mirror of
https://github.com/hydrosquall/tiingo-python.git
synced 2025-12-17 20:04:19 +01:00
Added api cleaning tools.
This commit is contained in:
51
tests/test_api_key_tools.py
Normal file
51
tests/test_api_key_tools.py
Normal file
@@ -0,0 +1,51 @@
|
||||
#
|
||||
# Test setup based on https://gist.github.com/odyniec/d4ea0959d4e0ba17a980
|
||||
#
|
||||
|
||||
import shutil, tempfile
|
||||
from os import path
|
||||
from unittest import TestCase
|
||||
from tools.api_key_tool import api_key_remover, api_key_detector
|
||||
|
||||
|
||||
class TestAPIKeyTools(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.test_dir = tempfile.mkdtemp()
|
||||
f = open(path.join(self.test_dir, 'test.yaml'), 'w')
|
||||
txt = '''interactions:
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept: ['*/*']
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Authorization: [Token a00000000000000000000a00000000000000000a]
|
||||
Connection: [keep-alive]
|
||||
Content-Type: [application/json]
|
||||
User-Agent: [tiingo-python-client 0.5.0]
|
||||
method: GET
|
||||
uri: https://api.tiingo.com/tiingo/daily/GOOGL/prices?format=json&resampleFreq=daily
|
||||
response:
|
||||
body: {string: '[{"adjClose":1037.29,"adjHigh":1044.65,"adjLow":1026.05,"adjOpen":1031.47,"adjVolume":1644794,"close":1037.29,"date":"2018-04-12T00:00:00+00:00","divCash":0.0,"high":1044.65,"low":1026.05,"open":1031.47,"splitFactor":1.0,"volume":1644794}]'}
|
||||
headers:
|
||||
Allow: ['GET, HEAD, OPTIONS']
|
||||
Content-Length: ['239']
|
||||
Content-Type: [application/json]
|
||||
Date: ['Fri, 13 Apr 2018 02:42:05 GMT']
|
||||
Server: [nginx/1.10.1]
|
||||
Vary: ['Accept, Cookie']
|
||||
X-Frame-Options: [SAMEORIGIN]
|
||||
status: {code: 200, message: OK}
|
||||
version: 1
|
||||
'''
|
||||
f.write(txt)
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.test_dir)
|
||||
|
||||
def test_key_detector(self):
|
||||
assert api_key_detector(path.join(self.test_dir, 'test.yaml')) is True
|
||||
|
||||
def test_key_remover(self):
|
||||
api_key_remover(path.join(self.test_dir, 'test.yaml'))
|
||||
assert api_key_detector(path.join(self.test_dir, 'test.yaml')) is False
|
||||
Reference in New Issue
Block a user