@@ 250-269 (lines=20) @@ | ||
247 | self.assertEqual(history[0].url, base_url) |
|
248 | self.assertTrue(mock_logger.debug.called) |
|
249 | ||
250 | def test_executeTrade(self, mock_logger, m): |
|
251 | '''Test function executeTrade.''' |
|
252 | trading_pair = 'btceur' |
|
253 | order_id = '1337' |
|
254 | params = {'amount_currency_to_trade': '10', |
|
255 | 'payment_option' : 2, |
|
256 | 'type': 'buy', |
|
257 | } |
|
258 | base_url = f'https://api.bitcoin.de/v4/{trading_pair}/trades/{order_id}' |
|
259 | url_args = '?' + urlencode(params) |
|
260 | response = self.sampleData('minimal') |
|
261 | m.post(requests_mock.ANY, json=response, status_code=201) |
|
262 | self.conn.executeTrade(trading_pair, |
|
263 | order_id, |
|
264 | params['type'], |
|
265 | params['amount_currency_to_trade']) |
|
266 | history = m.request_history |
|
267 | self.assertEqual(history[0].method, "POST") |
|
268 | self.assertEqual(history[0].url, base_url + url_args) |
|
269 | self.assertTrue(mock_logger.debug.called) |
|
270 | ||
271 | def test_showMyTrades(self, mock_logger, m): |
|
272 | '''Test function showMyTrades.''' |
|
@@ 341-356 (lines=16) @@ | ||
338 | self.assertEqual(history[0].url, base_url + url_args) |
|
339 | self.assertTrue(mock_logger.debug.called) |
|
340 | ||
341 | def test_markCoinsAsReceived(self, mock_logger, m): |
|
342 | '''Test function markCoinsAsReceived.''' |
|
343 | trading_pair = 'btceur' |
|
344 | trade_id = '1337' |
|
345 | params = { 'amount_currency_to_trade_after_fee': 0.1337, 'rating': 'positive'} |
|
346 | url_args = '?' + urlencode(params) |
|
347 | base_url = f'https://api.bitcoin.de/v4/{trading_pair}/trades/{trade_id}/mark_coins_as_received' |
|
348 | response = self.sampleData('markCoinsAsTransferred') |
|
349 | m.post(requests_mock.ANY, json=response, status_code=200) |
|
350 | self.conn.markCoinsAsReceived(trading_pair, trade_id, |
|
351 | params['amount_currency_to_trade_after_fee'], |
|
352 | params['rating']) |
|
353 | history = m.request_history |
|
354 | self.assertEqual(history[0].method, "POST") |
|
355 | self.assertEqual(history[0].url, base_url + url_args) |
|
356 | self.assertTrue(mock_logger.debug.called) |
|
357 | ||
358 | def test_markTradeAsPaymentReceived(self, mock_logger, m): |
|
359 | '''Test function markTradeAsPaymentReceived.''' |
|
@@ 158-173 (lines=16) @@ | ||
155 | self.assertEqual(history[0].url, base_url) |
|
156 | self.assertTrue(mock_logger.debug.called) |
|
157 | ||
158 | def test_show_orderbook(self, mock_logger, m): |
|
159 | '''Test function showOrderbook.''' |
|
160 | trading_pair = 'btceur' |
|
161 | params = {'price': 1337, |
|
162 | 'type': 'buy'} |
|
163 | base_url = f'https://api.bitcoin.de/v4/{trading_pair}/orderbook' |
|
164 | url_args = '?' + urlencode(params) |
|
165 | response = self.sampleData('showOrderbook_buy') |
|
166 | m.get(requests_mock.ANY, json=response, status_code=200) |
|
167 | self.conn.showOrderbook(params['type'], |
|
168 | trading_pair, |
|
169 | price=params['price']) |
|
170 | history = m.request_history |
|
171 | self.assertEqual(history[0].method, "GET") |
|
172 | self.assertEqual(history[0].url, base_url + url_args) |
|
173 | self.assertTrue(mock_logger.debug.called) |
|
174 | ||
175 | def test_showOrderDetails(self, mock_logger, m): |
|
176 | '''Test function showOrderDetails.''' |
|
@@ 377-390 (lines=14) @@ | ||
374 | self.assertEqual(history[0].url, base_url + url_args) |
|
375 | self.assertTrue(mock_logger.debug.called) |
|
376 | ||
377 | def test_addTradeRating(self, mock_logger, m): |
|
378 | '''Test function addTradeRating.''' |
|
379 | trading_pair = 'btceur' |
|
380 | trade_id = '1337' |
|
381 | params = { 'rating': 'positive' } |
|
382 | url_args = '?' + urlencode(params) |
|
383 | base_url = f'https://api.bitcoin.de/v4/{trading_pair}/trades/{trade_id}/add_trade_rating' |
|
384 | response = self.sampleData('markCoinsAsTransferred') |
|
385 | m.post(requests_mock.ANY, json=response, status_code=200) |
|
386 | self.conn.addTradeRating(trading_pair, trade_id, params['rating']) |
|
387 | history = m.request_history |
|
388 | self.assertEqual(history[0].method, "POST") |
|
389 | self.assertEqual(history[0].url, base_url + url_args) |
|
390 | self.assertTrue(mock_logger.debug.called) |
|
391 | ||
392 | def test_showAccountInfo(self, mock_logger, m): |
|
393 | '''Test function showAccountInfo.''' |
|
@@ 326-339 (lines=14) @@ | ||
323 | self.assertEqual(history[0].url, base_url + url_args) |
|
324 | self.assertTrue(mock_logger.debug.called) |
|
325 | ||
326 | def test_markTradeAsPaid(self, mock_logger, m): |
|
327 | '''Test function markTradeAsPaid.''' |
|
328 | trading_pair = 'btceur' |
|
329 | trade_id = '1337' |
|
330 | params = { 'volume_currency_to_pay_after_fee': 0.1337} |
|
331 | url_args = '?' + urlencode(params) |
|
332 | base_url = f'https://api.bitcoin.de/v4/{trading_pair}/trades/{trade_id}/mark_trade_as_paid' |
|
333 | response = self.sampleData('markCoinsAsTransferred') |
|
334 | m.post(requests_mock.ANY, json=response, status_code=200) |
|
335 | self.conn.markTradeAsPaid(trading_pair, trade_id, params['volume_currency_to_pay_after_fee']) |
|
336 | history = m.request_history |
|
337 | self.assertEqual(history[0].method, "POST") |
|
338 | self.assertEqual(history[0].url, base_url + url_args) |
|
339 | self.assertTrue(mock_logger.debug.called) |
|
340 | ||
341 | def test_markCoinsAsReceived(self, mock_logger, m): |
|
342 | '''Test function markCoinsAsReceived.''' |
|
@@ 311-324 (lines=14) @@ | ||
308 | self.assertEqual(history[0].url, base_url) |
|
309 | self.assertTrue(mock_logger.debug.called) |
|
310 | ||
311 | def test_markCoinsAsTransferred(self, mock_logger, m): |
|
312 | '''Test function markCoinsAsTransferred.''' |
|
313 | trading_pair = 'btceur' |
|
314 | trade_id = '1337' |
|
315 | params = { 'amount_currency_to_trade_after_fee': 0.1337} |
|
316 | url_args = '?' + urlencode(params) |
|
317 | base_url = f'https://api.bitcoin.de/v4/{trading_pair}/trades/{trade_id}/mark_coins_as_transferred' |
|
318 | response = self.sampleData('markCoinsAsTransferred') |
|
319 | m.post(requests_mock.ANY, json=response, status_code=200) |
|
320 | self.conn.markCoinsAsTransferred(trading_pair, trade_id, params['amount_currency_to_trade_after_fee']) |
|
321 | history = m.request_history |
|
322 | self.assertEqual(history[0].method, "POST") |
|
323 | self.assertEqual(history[0].url, base_url + url_args) |
|
324 | self.assertTrue(mock_logger.debug.called) |
|
325 | ||
326 | def test_markTradeAsPaid(self, mock_logger, m): |
|
327 | '''Test function markTradeAsPaid.''' |