(self, exchange_name, exchange_data, test_name=None)
| 1059 | return exchange |
| 1060 | |
| 1061 | def test_exchange_request_statically(self, exchange_name, exchange_data, test_name=None): |
| 1062 | # instantiate the exchange and make sure that we sink the requests to avoid an actual request |
| 1063 | exchange = self.init_offline_exchange(exchange_name) |
| 1064 | global_options = exchange.safe_dict(exchange_data, 'options', {}) |
| 1065 | # read apiKey/secret from the test file |
| 1066 | api_key = exchange.safe_string(exchange_data, 'apiKey') |
| 1067 | if not exchange.is_empty_string(api_key): |
| 1068 | exchange.apiKey = str(api_key) |
| 1069 | secret = exchange.safe_string(exchange_data, 'secret') |
| 1070 | if not exchange.is_empty_string(secret): |
| 1071 | exchange.secret = str(secret) |
| 1072 | private_key = exchange.safe_string(exchange_data, 'privateKey') |
| 1073 | if not exchange.is_empty_string(private_key): |
| 1074 | exchange.privateKey = str(private_key) |
| 1075 | wallet_address = exchange.safe_string(exchange_data, 'walletAddress') |
| 1076 | if not exchange.is_empty_string(wallet_address): |
| 1077 | exchange.walletAddress = str(wallet_address) |
| 1078 | accounts = exchange.safe_list(exchange_data, 'accounts') |
| 1079 | if accounts: |
| 1080 | exchange.accounts = accounts |
| 1081 | # exchange.options = exchange.deepExtend (exchange.options, globalOptions); # custom options to be used in the tests |
| 1082 | exchange.extend_exchange_options(global_options) |
| 1083 | methods = exchange.safe_value(exchange_data, 'methods', {}) |
| 1084 | methods_names = list(methods.keys()) |
| 1085 | for i in range(0, len(methods_names)): |
| 1086 | method = methods_names[i] |
| 1087 | results = methods[method] |
| 1088 | for j in range(0, len(results)): |
| 1089 | result = results[j] |
| 1090 | old_exchange_options = exchange.options # snapshot options; |
| 1091 | test_exchange_options = exchange.safe_value(result, 'options', {}) |
| 1092 | # exchange.options = exchange.deepExtend (oldExchangeOptions, testExchangeOptions); # custom options to be used in the tests |
| 1093 | exchange.extend_exchange_options(exchange.deep_extend(old_exchange_options, test_exchange_options)) |
| 1094 | description = exchange.safe_value(result, 'description') |
| 1095 | if (test_name is not None) and (test_name != description): |
| 1096 | continue |
| 1097 | is_disabled = exchange.safe_bool(result, 'disabled', False) |
| 1098 | if is_disabled: |
| 1099 | continue |
| 1100 | disabled_string = exchange.safe_string(result, 'disabled', '') |
| 1101 | if disabled_string != '': |
| 1102 | continue |
| 1103 | is_disabled_c_sharp = exchange.safe_bool(result, 'disabledCS', False) |
| 1104 | if is_disabled_c_sharp and (self.lang == 'C#'): |
| 1105 | continue |
| 1106 | is_disabled_go = exchange.safe_bool(result, 'disabledGO', False) |
| 1107 | if is_disabled_go and (self.lang == 'GO'): |
| 1108 | continue |
| 1109 | is_disabled_java = exchange.safe_bool(result, 'disabledJava', False) |
| 1110 | if is_disabled_java and (self.lang == 'java'): |
| 1111 | continue |
| 1112 | type = exchange.safe_string(exchange_data, 'outputType') |
| 1113 | skip_keys = exchange.safe_value(exchange_data, 'skipKeys', []) |
| 1114 | self.test_request_statically(exchange, method, result, type, skip_keys) |
| 1115 | # reset options |
| 1116 | exchange.options = exchange.convert_to_safe_dictionary(exchange.deep_extend(old_exchange_options, {})) |
| 1117 | if not is_sync(): |
| 1118 | close(exchange) |
no test coverage detected