Skip to content

Commit

Permalink
adds missing coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgolec committed Jun 17, 2024
1 parent e3e8e81 commit eb71d17
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion schwab/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def callback_server():
# XXX: We're detecting a test environment here to avoid an
# infinite sleep. Surely there must be a better way to do
# this...
if __TIME_TIME != time.time:
if __TIME_TIME != time.time: # pragma: no cover
raise ValueError('endless wait requested')
continue

Check warning on line 404 in schwab/auth.py

View check run for this annotation

Codecov / codecov/patch

schwab/auth.py#L404

Added line #L404 was not covered by tests
else:
Expand Down
16 changes: 16 additions & 0 deletions tests/auth_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,22 @@ def test_disallowed_hostname(
API_KEY, APP_SECRET, callback_url, self.token_path)


@patch('schwab.auth.Client')
@patch('schwab.auth.OAuth2Client', new_callable=MockOAuthClient)
@patch('schwab.auth.AsyncOAuth2Client', new_callable=MockAsyncOAuthClient)
@patch('schwab.auth.webbrowser.get', new_callable=MagicMock)
@patch('time.time', MagicMock(return_value=MOCK_NOW))
def test_negative_timeout(
self, mock_webbrowser_get, async_session, sync_session, client):
callback_url = 'https://example.com/callback'

with self.assertRaisesRegex(
ValueError, 'callback_timeout must be positive'):
auth.client_from_login_flow(
API_KEY, APP_SECRET, callback_url, self.token_path,
callback_timeout=-1)


@patch('schwab.auth.Client')
@patch('schwab.auth.OAuth2Client', new_callable=MockOAuthClient)
@patch('schwab.auth.AsyncOAuth2Client', new_callable=MockAsyncOAuthClient)
Expand Down

0 comments on commit eb71d17

Please sign in to comment.