Skip to content
This repository was archived by the owner on Aug 20, 2025. It is now read-only.

Commit 19e1601

Browse files
committed
updating unit tests
1 parent e5dbc78 commit 19e1601

File tree

2 files changed

+29
-22
lines changed

2 files changed

+29
-22
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ print api.getGains()
4747
```
4848
venv/bin/python -m unittest -v ctapi.test.ctapi_tests
4949
```
50+
**be aware of the API requests limit of 20 req/h**
5051

5152
# Contribute
5253
Do you have an idea or found a bug in python-ctapi? Please file an issue and make a PR! :)

ctapi/test/ctapi_tests.py

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,14 @@
1010
except Exception:
1111
IS_CI_ENV = True
1212

13-
# def test_basic_response(unit_test, result, method_name):
14-
# unit_test.assertTrue(result['success'], "{0:s} failed".format(method_name))
15-
# unit_test.assertTrue(result['message'] is not None, "message not present in response")
16-
# unit_test.assertTrue(result['result'] is not None, "result not present in response")
17-
18-
19-
# {'result': {u'error_msg': u'ERROR: Sign is not correct', u'method': u'getBalance', u'success': 0, u'error': u'SIGN_INCORRECT'}, 'success': True}
20-
# {'result': {u'error_msg': u'ERROR: API Key not set', u'method': u'getBalance', u'success': 0, u'error': u'KEY_MISSING'}, 'success': True}
21-
# {'result': {u'error_msg': u'ERROR: Sign is not correct', u'method': u'getBalance', u'success': 0, u'error': u'SIGN_INCORRECT'}, 'success': True}
22-
23-
def test_auth_basic_failures(unit_test, result, test_type):
24-
pass
25-
26-
# unit_test.assertFalse(result['success'], "{0:s} failed".format(test_type))
27-
# unit_test.assertTrue('invalid' in str(result['message']).lower(), "{0:s} failed response message".format(test_type))
28-
# unit_test.assertIsNone(result['result'], "{0:s} failed response result not None".format(test_type))
29-
13+
def test_basic_response(unit_test, result, method_name):
14+
unit_test.assertTrue(result['success'], "%s failed" % method_name)
15+
unit_test.assertTrue(result['result'] is not None, "result not present in response")
16+
unit_test.assertTrue(isinstance(result['result'], dict), "result is not a dict")
17+
# unit_test.assertTrue(result['result']['method'] is method_name, "result method is wrong")
3018

3119
@unittest.skipIf(IS_CI_ENV, 'no account secrets uploaded in CI envieonment, TODO')
32-
class TestCoinTrackingAPIBasicTests(unittest.TestCase):
20+
class TestCTAPIBasicTests(unittest.TestCase):
3321
"""
3422
Integration tests for the CoinTracking API
3523
@@ -72,11 +60,29 @@ def test_handles_invalid_key_or_secret(self):
7260
actual = self.api.getBalance()
7361
self.assertFalse(actual['success'], 'invalid key, invalid secret')
7462

75-
# def test_get_balances(self):
76-
# actual = self.bittrex.get_balances()
77-
# test_basic_response(self, actual, "get_balances")
78-
# self.assertTrue(isinstance(actual['result'], list), "result is not a list")
63+
def test_getTrades(self):
64+
actual = self.api.getTrades()
65+
test_basic_response(self, actual, "getTrades")
66+
67+
def test_getBalance(self):
68+
actual = self.api.getBalance()
69+
test_basic_response(self, actual, "getBalance")
70+
71+
def test_getHistoricalSummary(self):
72+
actual = self.api.getHistoricalSummary()
73+
test_basic_response(self, actual, "getHistoricalSummary")
74+
75+
def test_getHistoricalCurrency(self):
76+
actual = self.api.getHistoricalCurrency()
77+
test_basic_response(self, actual, "getHistoricalCurrency")
78+
79+
def test_getGroupedBalance(self):
80+
actual = self.api.getGroupedBalance()
81+
test_basic_response(self, actual, "getGroupedBalance")
7982

83+
def test_getGains(self):
84+
actual = self.api.getGains()
85+
test_basic_response(self, actual, "getGains")
8086

8187
if __name__ == '__main__':
8288
unittest.main()

0 commit comments

Comments
 (0)