Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion massive/rest/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ def _get_params(
# https://docs.python.org/3.8/library/inspect.html#inspect.Signature
for argname, v in inspect.signature(fn).parameters.items():
# https://docs.python.org/3.8/library/inspect.html#inspect.Parameter
if argname in ["params", "raw"]:
# these configure the request itself and are never query params
if argname in ["params", "raw", "options"]:
continue
if v.default != v.empty:
# timestamp_lt -> timestamp.lt
Expand Down
35 changes: 35 additions & 0 deletions test_rest/test_request_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from massive.rest.models.request import RequestOptionBuilder
from base import BaseTest

import pook # type: ignore


class RequestOptionsTest(BaseTest):
"""`options` sets headers; it must not leak into the query string."""

def options(self):
return RequestOptionBuilder(edge_id="test-edge", edge_ip_address="1.2.3.4")

def assert_no_options_in_query(self, mock):
self.assertEqual(len(mock.matches), 1)
self.assertNotIn("options", mock.matches[0].query or {})

def test_get_with_options(self):
mock = pook.get(
self.c.BASE + "/v3/reference/tickers/OPTS",
reply=200,
response_body='{"results": {"ticker": "OPTS"}}',
)
details = self.c.get_ticker_details("OPTS", options=self.options())
self.assertEqual(details.ticker, "OPTS")
self.assert_no_options_in_query(mock)

def test_paginate_with_options(self):
mock = pook.get(
self.c.BASE + "/v3/trades/OPTS",
reply=200,
response_body='{"results": []}',
)
trades = list(self.c.list_trades("OPTS", options=self.options()))
self.assertEqual(trades, [])
self.assert_no_options_in_query(mock)
Loading