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

Method assert_static_request_output

python/ccxt/test/tests_async.py:897–935  ·  view source on GitHub ↗
(self, exchange, type, skip_keys, stored_url, request_url, stored_output, new_output)

Source from the content-addressed store, hash-verified

895 return new_string
896
897 def assert_static_request_output(self, exchange, type, skip_keys, stored_url, request_url, stored_output, new_output):
898 if stored_url != request_url:
899 # remove the host part from the url
900 first_path = self.remove_hostnamefrom_url(stored_url)
901 second_path = self.remove_hostnamefrom_url(request_url)
902 self.assert_static_error(first_path == second_path, 'url mismatch', first_path, second_path)
903 # body (aka storedOutput and newOutput) is not defined and information is in the url
904 # example: "https://open-api.bingx.com/openApi/spot/v1/trade/order?quoteOrderQty=5&side=BUY&symbol=LTC-USDT&timestamp=1698777135343&type=MARKET&signature=d55a7e4f7f9dbe56c4004c9f3ab340869d3cb004e2f0b5b861e5fbd1762fd9a0
905 if (stored_output is None) and (new_output is None):
906 if (stored_url is not None) and (request_url is not None):
907 stored_url_parts = stored_url.split('?')
908 new_url_parts = request_url.split('?')
909 stored_url_query = exchange.safe_value(stored_url_parts, 1)
910 new_url_query = exchange.safe_value(new_url_parts, 1)
911 if (stored_url_query is None) and (new_url_query is None):
912 # might be a get request without any query parameters
913 # example: https://api.gateio.ws/api/v4/delivery/usdt/positions
914 return True
915 stored_url_params = self.urlencoded_to_dict(stored_url_query)
916 new_url_params = self.urlencoded_to_dict(new_url_query)
917 self.assert_new_and_stored_output(exchange, skip_keys, new_url_params, stored_url_params)
918 return True
919 if type == 'json' and (stored_output is not None) and (new_output is not None):
920 if isinstance(stored_output, str):
921 stored_output = json_parse(stored_output)
922 if isinstance(new_output, str):
923 new_output = json_parse(new_output)
924 elif type == 'urlencoded' and (stored_output is not None) and (new_output is not None):
925 stored_output = self.urlencoded_to_dict(stored_output)
926 new_output = self.urlencoded_to_dict(new_output)
927 elif type == 'both':
928 if stored_output.startswith('{') or stored_output.startswith('['):
929 stored_output = json_parse(stored_output)
930 new_output = json_parse(new_output)
931 else:
932 stored_output = self.urlencoded_to_dict(stored_output)
933 new_output = self.urlencoded_to_dict(new_output)
934 self.assert_new_and_stored_output(exchange, skip_keys, new_output, stored_output)
935 return True
936
937 def assert_static_response_output(self, exchange, skip_keys, computed_result, stored_result):
938 self.assert_new_and_stored_output(exchange, skip_keys, computed_result, stored_result, False)

Callers 1

Calls 7

assert_static_errorMethod · 0.95
urlencoded_to_dictMethod · 0.95
json_parseFunction · 0.90
splitMethod · 0.80
safe_valueMethod · 0.80

Tested by

no test coverage detected