MCPcopy Index your code
hub / github.com/ccxt/ccxt / test_exchange_request_statically

Method test_exchange_request_statically

python/ccxt/test/tests_async.py:1064–1122  ·  view source on GitHub ↗
(self, exchange_name, exchange_data, test_name=None)

Source from the content-addressed store, hash-verified

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

Callers 1

run_static_testsMethod · 0.95

Calls 14

init_offline_exchangeMethod · 0.95
is_syncFunction · 0.90
closeFunction · 0.90
safe_dictMethod · 0.80
safe_stringMethod · 0.80
is_empty_stringMethod · 0.80
safe_listMethod · 0.80
safe_valueMethod · 0.80
deep_extendMethod · 0.80
safe_boolMethod · 0.80

Tested by

no test coverage detected