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

Method assert_static_request_output

python/ccxt/test/tests_sync.py:894–932  ·  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

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