|
@@ 191-203 (lines=13) @@
|
| 188 |
|
self.assertEqual(history[0].url, base_url + url_args) |
| 189 |
|
self.assertTrue(mock_logger.debug.called) |
| 190 |
|
|
| 191 |
|
def test_showMyOrderDetails(self, mock_logger, m): |
| 192 |
|
'''Test function showMyOrderDetails.''' |
| 193 |
|
params = {'order_id': '1337'} |
| 194 |
|
base_url = 'https://api.bitcoin.de/v2/orders/{}'\ |
| 195 |
|
.format(params.get('order_id')) |
| 196 |
|
url_args = '' |
| 197 |
|
response = self.sampleData('showMyOrderDetails') |
| 198 |
|
m.get(requests_mock.ANY, json=response, status_code=200) |
| 199 |
|
self.conn.showMyOrderDetails(params.get('order_id')) |
| 200 |
|
history = m.request_history |
| 201 |
|
self.assertEqual(history[0].method, "GET") |
| 202 |
|
self.assertEqual(history[0].url, base_url + url_args) |
| 203 |
|
self.assertTrue(mock_logger.debug.called) |
| 204 |
|
|
| 205 |
|
def test_executeTrade(self, mock_logger, m): |
| 206 |
|
'''Test function executeTrade.''' |
|
@@ 338-349 (lines=12) @@
|
| 335 |
|
self.assertEqual(history[0].url, base_url + url_args) |
| 336 |
|
self.assertTrue(mock_logger.debug.called) |
| 337 |
|
|
| 338 |
|
def test_showAccountLedger(self, mock_logger, m): |
| 339 |
|
'''Test function showAccountLedger.''' |
| 340 |
|
params = {'currency': 'btc'} |
| 341 |
|
base_url = 'https://api.bitcoin.de/v2/account/ledger' |
| 342 |
|
url_args = '?currency={}'.format(params.get('currency')) |
| 343 |
|
response = self.sampleData('showAccountLedger') |
| 344 |
|
m.get(requests_mock.ANY, json=response, status_code=200) |
| 345 |
|
self.conn.showAccountLedger(params.get('currency')) |
| 346 |
|
history = m.request_history |
| 347 |
|
self.assertEqual(history[0].method, "GET") |
| 348 |
|
self.assertEqual(history[0].url, base_url + url_args) |
| 349 |
|
self.assertTrue(mock_logger.debug.called) |
| 350 |
|
|
| 351 |
|
|
| 352 |
|
class TestBtcdeExceptions(TestCase): |
|
@@ 325-336 (lines=12) @@
|
| 322 |
|
self.assertEqual(history[0].url, base_url + url_args) |
| 323 |
|
self.assertTrue(mock_logger.debug.called) |
| 324 |
|
|
| 325 |
|
def test_showRates(self, mock_logger, m): |
| 326 |
|
'''Test function showRates.''' |
| 327 |
|
params = {'trading_pair': 'btceur'} |
| 328 |
|
base_url = 'https://api.bitcoin.de/v2/rates' |
| 329 |
|
url_args = '?trading_pair={}'.format(params.get('trading_pair')) |
| 330 |
|
response = self.sampleData('showRates') |
| 331 |
|
m.get(requests_mock.ANY, json=response, status_code=200) |
| 332 |
|
self.conn.showRates(params.get('trading_pair')) |
| 333 |
|
history = m.request_history |
| 334 |
|
self.assertEqual(history[0].method, "GET") |
| 335 |
|
self.assertEqual(history[0].url, base_url + url_args) |
| 336 |
|
self.assertTrue(mock_logger.debug.called) |
| 337 |
|
|
| 338 |
|
def test_showAccountLedger(self, mock_logger, m): |
| 339 |
|
'''Test function showAccountLedger.''' |
|
@@ 297-308 (lines=12) @@
|
| 294 |
|
self.assertEqual(history[0].url, base_url + url_args) |
| 295 |
|
self.assertTrue(mock_logger.debug.called) |
| 296 |
|
|
| 297 |
|
def test_showPublicTradeHistory(self, mock_logger, m): |
| 298 |
|
'''Test function showPublicTradeHistory.''' |
| 299 |
|
params = {'trading_pair': 'btceur'} |
| 300 |
|
base_url = 'https://api.bitcoin.de/v2/trades/history' |
| 301 |
|
url_args = '?trading_pair={}'.format(params.get('trading_pair')) |
| 302 |
|
response = self.sampleData('showPublicTradeHistory') |
| 303 |
|
m.get(requests_mock.ANY, json=response, status_code=200) |
| 304 |
|
self.conn.showPublicTradeHistory(params.get('trading_pair')) |
| 305 |
|
history = m.request_history |
| 306 |
|
self.assertEqual(history[0].method, "GET") |
| 307 |
|
self.assertEqual(history[0].url, base_url + url_args) |
| 308 |
|
self.assertTrue(mock_logger.debug.called) |
| 309 |
|
|
| 310 |
|
def test_showPublicTradeHistory_since(self, mock_logger, m): |
| 311 |
|
'''Test function showPublicTradeHistory with since_tid.''' |
|
@@ 284-295 (lines=12) @@
|
| 281 |
|
self.assertEqual(history[0].url, base_url + url_args) |
| 282 |
|
self.assertTrue(mock_logger.debug.called) |
| 283 |
|
|
| 284 |
|
def test_showOrderbookCompact(self, mock_logger, m): |
| 285 |
|
'''Test function showOrderbookCompact.''' |
| 286 |
|
params = {'trading_pair': 'btceur'} |
| 287 |
|
base_url = 'https://api.bitcoin.de/v2/orders/compact' |
| 288 |
|
url_args = '?trading_pair={}'.format(params.get('trading_pair')) |
| 289 |
|
response = self.sampleData('showOrderbookCompact') |
| 290 |
|
m.get(requests_mock.ANY, json=response, status_code=200) |
| 291 |
|
self.conn.showOrderbookCompact(params.get('trading_pair')) |
| 292 |
|
history = m.request_history |
| 293 |
|
self.assertEqual(history[0].method, "GET") |
| 294 |
|
self.assertEqual(history[0].url, base_url + url_args) |
| 295 |
|
self.assertTrue(mock_logger.debug.called) |
| 296 |
|
|
| 297 |
|
def test_showPublicTradeHistory(self, mock_logger, m): |
| 298 |
|
'''Test function showPublicTradeHistory.''' |
|
@@ 259-270 (lines=12) @@
|
| 256 |
|
self.assertEqual(history[0].url, base_url + url_args) |
| 257 |
|
self.assertTrue(mock_logger.debug.called) |
| 258 |
|
|
| 259 |
|
def test_showMyTradeDetails(self, mock_logger, m): |
| 260 |
|
'''Test function showMyTradeDetails.''' |
| 261 |
|
params = {'trade_id': '1337'} |
| 262 |
|
base_url = 'https://api.bitcoin.de/v2/trades' |
| 263 |
|
url_args = '/{}'.format(params.get('trade_id')) |
| 264 |
|
response = self.sampleData('showMyTradeDetails') |
| 265 |
|
m.get(requests_mock.ANY, json=response, status_code=200) |
| 266 |
|
self.conn.showMyTradeDetails(params.get('trade_id')) |
| 267 |
|
history = m.request_history |
| 268 |
|
self.assertEqual(history[0].method, "GET") |
| 269 |
|
self.assertEqual(history[0].url, base_url + url_args) |
| 270 |
|
self.assertTrue(mock_logger.debug.called) |
| 271 |
|
|
| 272 |
|
def test_showAccountInfo(self, mock_logger, m): |
| 273 |
|
'''Test function showAccountInfo.''' |
|
@@ 272-282 (lines=11) @@
|
| 269 |
|
self.assertEqual(history[0].url, base_url + url_args) |
| 270 |
|
self.assertTrue(mock_logger.debug.called) |
| 271 |
|
|
| 272 |
|
def test_showAccountInfo(self, mock_logger, m): |
| 273 |
|
'''Test function showAccountInfo.''' |
| 274 |
|
base_url = 'https://api.bitcoin.de/v2/account' |
| 275 |
|
url_args = '' |
| 276 |
|
response = self.sampleData('showAccountInfo') |
| 277 |
|
m.get(requests_mock.ANY, json=response, status_code=200) |
| 278 |
|
self.conn.showAccountInfo() |
| 279 |
|
history = m.request_history |
| 280 |
|
self.assertEqual(history[0].method, "GET") |
| 281 |
|
self.assertEqual(history[0].url, base_url + url_args) |
| 282 |
|
self.assertTrue(mock_logger.debug.called) |
| 283 |
|
|
| 284 |
|
def test_showOrderbookCompact(self, mock_logger, m): |
| 285 |
|
'''Test function showOrderbookCompact.''' |
|
@@ 230-240 (lines=11) @@
|
| 227 |
|
self.assertEqual(history[0].url, base_url + url_args) |
| 228 |
|
self.assertTrue(mock_logger.debug.called) |
| 229 |
|
|
| 230 |
|
def test_showMyTrades(self, mock_logger, m): |
| 231 |
|
'''Test function showMyTrades.''' |
| 232 |
|
base_url = 'https://api.bitcoin.de/v2/trades' |
| 233 |
|
url_args = '' |
| 234 |
|
response = self.sampleData('showMyTrades') |
| 235 |
|
m.get(requests_mock.ANY, json=response, status_code=200) |
| 236 |
|
self.conn.showMyTrades() |
| 237 |
|
history = m.request_history |
| 238 |
|
self.assertEqual(history[0].method, "GET") |
| 239 |
|
self.assertEqual(history[0].url, base_url + url_args) |
| 240 |
|
self.assertTrue(mock_logger.debug.called) |
| 241 |
|
|
| 242 |
|
def test_showMyTrades_with_params(self, mock_logger, m): |
| 243 |
|
'''Test function showMyTrades with parameters.''' |
|
@@ 65-83 (lines=19) @@
|
| 62 |
|
del self.XAPISECRET |
| 63 |
|
del self.conn |
| 64 |
|
|
| 65 |
|
def test_signature_post(self, mock_logger, m): |
| 66 |
|
'''Test signature on a post request.''' |
| 67 |
|
params = {'type': 'buy', |
| 68 |
|
'trading_pair': 'btceur', |
| 69 |
|
'max_amount': 10, |
| 70 |
|
'price': 1337} |
| 71 |
|
response = self.sampleData('createOrder') |
| 72 |
|
m.post(requests_mock.ANY, json=response, status_code=201) |
| 73 |
|
self.conn.createOrder(params.get('type'), |
| 74 |
|
params.get('trading_pair'), |
| 75 |
|
params.get('max_amount'), |
| 76 |
|
params.get('price')) |
| 77 |
|
history = m.request_history |
| 78 |
|
request_signature = history[0].headers.get('X-API-SIGNATURE') |
| 79 |
|
verified_signature = self.verifySignature(self.conn.orderuri, |
| 80 |
|
'POST', |
| 81 |
|
params) |
| 82 |
|
self.assertEqual(request_signature, verified_signature) |
| 83 |
|
self.assertTrue(mock_logger.debug.called) |
| 84 |
|
|
| 85 |
|
def test_signature_get(self, mock_logger, m): |
| 86 |
|
'''Test signature on a get request.''' |
|
@@ 85-99 (lines=15) @@
|
| 82 |
|
self.assertEqual(request_signature, verified_signature) |
| 83 |
|
self.assertTrue(mock_logger.debug.called) |
| 84 |
|
|
| 85 |
|
def test_signature_get(self, mock_logger, m): |
| 86 |
|
'''Test signature on a get request.''' |
| 87 |
|
params = {'type': 'buy', |
| 88 |
|
'trading_pair': 'btceur'} |
| 89 |
|
response = self.sampleData('showOrderbook_buy') |
| 90 |
|
m.get(requests_mock.ANY, json=response, status_code=200) |
| 91 |
|
self.conn.showOrderbook(params.get('type'), |
| 92 |
|
params.get('trading_pair')) |
| 93 |
|
history = m.request_history |
| 94 |
|
request_signature = history[0].headers.get('X-API-SIGNATURE') |
| 95 |
|
verified_signature = self.verifySignature(self.conn.orderuri, |
| 96 |
|
'GET', |
| 97 |
|
params) |
| 98 |
|
self.assertEqual(request_signature, verified_signature) |
| 99 |
|
self.assertTrue(mock_logger.debug.called) |
| 100 |
|
|
| 101 |
|
def test_signature_delete(self, mock_logger, m): |
| 102 |
|
'''Test signature on a delete request.''' |