forked from ankurgajurel/nepse-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_all_data.py
More file actions
52 lines (43 loc) · 1.65 KB
/
Copy pathtest_all_data.py
File metadata and controls
52 lines (43 loc) · 1.65 KB
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
import unittest
import api.all_data
class TestAllData(unittest.TestCase):
def test_basic(self) -> None:
self.assertIsInstance(all_data.send_req_basic('adbl'), dict)
def test_nepse(self) -> None:
"""
tests if live index is float, percent-change is float and status is a dict with val True or False
"""
self.assertIsInstance(float(all_data.send_req_nepse('live')), float)
self.assertIsInstance(float(all_data.send_req_nepse('percent_change')), float)
self.assertIsInstance(all_data.send_req_nepse('status'), dict)
def test_news(self) -> None:
"""
tests if the news are in a list
"""
self.assertIsInstance(all_data.send_req_news(), list)
def test_scrip_data(self) -> None:
"""
tests if scrip data is a tuple of floats
"""
scrip_data = all_data.send_req_scrip_data('adbl')
self.assertIsInstance(scrip_data, tuple)
for val in scrip_data:
self.assertIsInstance(val, float)
def test_top_stocks(self) -> None:
"""
tests if the top stocks data is in list format
"""
n = 5
field = 'gainer'
field2 = 'looser'
for i in range(n):
self.assertIsInstance(all_data.send_req_top_stocks(i, field), list)
for i in range(n):
self.assertIsInstance(all_data.send_req_top_stocks(i, field2), list)
def test_indices(self) -> None:
"""
tests is indices data is in dictionary fomat
"""
self.assertIsInstance(all_data.send_req_indices('devbank'), dict)
if __name__ == '__main__':
unittest.main()