()
| 19 | return a == b |
| 20 | |
| 21 | def test_safe_methods(): |
| 22 | exchange = ccxt.Exchange({ |
| 23 | 'id': 'regirock', |
| 24 | }) |
| 25 | input_dict = { |
| 26 | 'i': 1, |
| 27 | 'f': 0.123, |
| 28 | 'bool': True, |
| 29 | 'list': [1, 2, 3], |
| 30 | 'dict': { |
| 31 | 'a': 1, |
| 32 | }, |
| 33 | 'listOfDicts': [{ |
| 34 | 'a': 1, |
| 35 | }], |
| 36 | 'str': 'heLlo', |
| 37 | 'strNumber': '3', |
| 38 | 'zeroNumeric': 0, |
| 39 | 'zeroString': '0', |
| 40 | 'undefined': None, |
| 41 | 'emptyString': '', |
| 42 | 'floatNumeric': 0.123, |
| 43 | 'floatString': '0.123', |
| 44 | 'longInt': 123456789012345, |
| 45 | } |
| 46 | input_list = ['Hi', 2] |
| 47 | compare_dict = { |
| 48 | 'a': 1, |
| 49 | } |
| 50 | compare_list = [1, 2, 3] |
| 51 | factor = 10 |
| 52 | # safeValue |
| 53 | assert exchange.safe_value(input_dict, 'i') == 1 |
| 54 | assert exchange.safe_value(input_dict, 'f') == 0.123 |
| 55 | assert exchange.safe_value(input_dict, 'bool') |
| 56 | assert equals(exchange.safe_value(input_dict, 'list'), compare_list) |
| 57 | dict_object = exchange.safe_value(input_dict, 'dict') |
| 58 | assert equals(dict_object, compare_dict) |
| 59 | assert exchange.safe_value(input_dict, 'str') == 'heLlo' |
| 60 | assert exchange.safe_value(input_dict, 'strNumber') == '3' |
| 61 | assert exchange.safe_value(input_list, 0) == 'Hi' |
| 62 | # safeValue2 |
| 63 | assert exchange.safe_value_2(input_dict, 'a', 'i') == 1 |
| 64 | assert exchange.safe_value_2(input_dict, 'a', 'f') == 0.123 |
| 65 | assert exchange.safe_value_2(input_dict, 'a', 'bool') |
| 66 | assert equals(exchange.safe_value_2(input_dict, 'a', 'list'), compare_list) |
| 67 | dict_object = exchange.safe_value_2(input_dict, 'a', 'dict') |
| 68 | assert equals(dict_object, compare_dict) |
| 69 | assert exchange.safe_value_2(input_dict, 'a', 'str') == 'heLlo' |
| 70 | assert exchange.safe_value_2(input_dict, 'a', 'strNumber') == '3' |
| 71 | assert exchange.safe_value_2(input_list, 2, 0) == 'Hi' |
| 72 | # safeValueN |
| 73 | assert exchange.safe_value_n(input_dict, ['a', 'b', 'i']) == 1 |
| 74 | assert exchange.safe_value_n(input_dict, ['a', 'b', 'f']) == 0.123 |
| 75 | assert exchange.safe_value_n(input_dict, ['a', 'b', 'bool']) |
| 76 | assert equals(exchange.safe_value_n(input_dict, ['a', 'b', 'list']), compare_list) |
| 77 | dict_object = exchange.safe_value_n(input_dict, ['a', 'b', 'dict']) |
| 78 | assert equals(dict_object, compare_dict) |
no test coverage detected
searching dependent graphs…