forked from quandl/quandl-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_point_in_time.py
65 lines (55 loc) · 1.98 KB
/
test_point_in_time.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import json
import re
import httpretty
from mock import call, patch
from quandl.model.point_in_time import PointInTime
from test.test_retries import ModifyRetrySettingsTestCase
from quandl.utils.request_type_util import RequestType
class GetPointInTimeTest(ModifyRetrySettingsTestCase):
@classmethod
def setUpClass(cls):
httpretty.enable()
httpretty.register_uri(httpretty.GET,
re.compile('https://data.nasdaq.com/api/v3/pit/*'),
body=json.dumps({}))
@classmethod
def tearDownClass(cls):
httpretty.disable()
httpretty.reset()
def tearDown(self):
RequestType.USE_GET_REQUEST = True
@patch('quandl.connection.Connection.request')
def test_asofdate_call_connection(self, mock):
PointInTime(
'ZACKS/FC',
pit={
'interval': 'asofdate',
'date': '2020-01-01'
}
).data()
expected = call('get', 'pit/ZACKS/FC/asofdate/2020-01-01', params={})
self.assertEqual(mock.call_args, expected)
@patch('quandl.connection.Connection.request')
def test_from_call_connection(self, mock):
PointInTime(
'ZACKS/FC',
pit={
'interval': 'from',
'start_date': '2020-01-01',
'end_date': '2020-01-02'
}
).data()
expected = call('get', 'pit/ZACKS/FC/from/2020-01-01/to/2020-01-02', params={})
self.assertEqual(mock.call_args, expected)
@patch('quandl.connection.Connection.request')
def test_between_call_connection(self, mock):
PointInTime(
'ZACKS/FC',
pit={
'interval': 'between',
'start_date': '2020-01-01',
'end_date': '2020-01-02'
}
).data()
expected = call('get', 'pit/ZACKS/FC/between/2020-01-01/2020-01-02', params={})
self.assertEqual(mock.call_args, expected)