Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patched up test coverage in client #47

Merged
merged 1 commit into from
May 7, 2024
Merged
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
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
Loading