Skip to content

Commit

Permalink
Patched up test coverage in client
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgolec committed May 7, 2024
1 parent 6893b6e commit 8f5b7ca
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
12 changes: 0 additions & 12 deletions schwab/client/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,6 @@ async def _put_request(self, path, data):
register_redactions_from_response(resp)
return resp

async def _patch_request(self, path, data):
dest = 'https://api.schwabapi.com' + path

req_num = self._req_num()
self.logger.debug('Req %s: PATCH to %s, json=%s',
req_num, dest, LazyLog(lambda: json.dumps(data, indent=4)))

resp = await self.session.patch(dest, json=data)
self._log_response(resp, req_num)
register_redactions_from_response(resp)
return resp

async def _delete_request(self, path):
dest = 'https://api.schwabapi.com' + path

Expand Down
12 changes: 0 additions & 12 deletions schwab/client/synchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,6 @@ def _put_request(self, path, data):
register_redactions_from_response(resp)
return resp

def _patch_request(self, path, data):
dest = 'https://api.schwabapi.com' + path

req_num = self._req_num()
self.logger.debug('Req %s: PATCH to %s, json=%s',
req_num, dest, LazyLog(lambda: json.dumps(data, indent=4)))

resp = self.session.patch(dest, json=data)
self._log_response(resp, req_num)
register_redactions_from_response(resp)
return resp

def _delete_request(self, path):
dest = 'https://api.schwabapi.com' + path

Expand Down
20 changes: 20 additions & 0 deletions tests/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,26 @@ def test_replace_order_str(self):
json=order_spec)


# preview_order


def test_preview_order(self):
order_spec = {'order': 'spec'}
self.client.preview_order(ACCOUNT_HASH, order_spec)
self.mock_session.post.assert_called_once_with(
self.make_url('/trader/v1/accounts/{accountHash}/previewOrder'),
json=order_spec)


def test_preview_order_order_builder(self):
order_spec = OrderBuilder(enforce_enums=False).set_order_type('LIMIT')
expected_spec = {'orderType': 'LIMIT'}
self.client.preview_order(ACCOUNT_HASH, order_spec)
self.mock_session.post.assert_called_once_with(
self.make_url('/trader/v1/accounts/{accountHash}/previewOrder'),
json=expected_spec)


# get_transactions


Expand Down

0 comments on commit 8f5b7ca

Please sign in to comment.