-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor all request methods to use helper method
- Loading branch information
Showing
14 changed files
with
327 additions
and
1,039 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
__version__ = "2.0.0" | ||
__version__ = "2.1.0" | ||
__all__ = [ | ||
"RobinhoodClient", | ||
# exceptions | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ Indices and tables | |
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` | ||
* :ref:`search` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ Reference | |
|
||
Client <client> | ||
Exceptions <exceptions> | ||
Models <models> | ||
Models <models> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import asyncio | ||
|
||
import pytest | ||
|
||
from aiorobinhood import ClientAPIError, ClientRequestError | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_request_api_error(logged_in_client): | ||
client, server = logged_in_client | ||
task = asyncio.create_task(client.request("GET", pytest.NEXT)) | ||
|
||
request = await server.receive_request(timeout=pytest.TIMEOUT) | ||
assert request.method == "GET" | ||
assert request.path == pytest.NEXT.path | ||
server.send_response(request, status=400, content_type="application/json") | ||
|
||
with pytest.raises(ClientAPIError): | ||
await task | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_request_timeout_error(logged_in_client): | ||
client, server = logged_in_client | ||
task = asyncio.create_task(client.request("GET", pytest.NEXT)) | ||
|
||
request = await server.receive_request(timeout=pytest.TIMEOUT) | ||
assert request.method == "GET" | ||
assert request.path == pytest.NEXT.path | ||
|
||
with pytest.raises(ClientRequestError) as exc_info: | ||
await asyncio.sleep(pytest.TIMEOUT + 1) | ||
await task | ||
assert isinstance(exc_info.value.__cause__, asyncio.TimeoutError) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
import aiohttp | ||
import pytest | ||
|
||
from aiorobinhood import RobinhoodClient | ||
from aiorobinhood import ClientUninitializedError, RobinhoodClient | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_async_context_manager(): | ||
async with RobinhoodClient(timeout=pytest.TIMEOUT) as client: | ||
assert client._session is not None | ||
assert isinstance(client._session, aiohttp.ClientSession) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_async_context_manager_client_uninitialized_error(): | ||
with pytest.raises(ClientUninitializedError): | ||
async with RobinhoodClient(timeout=pytest.TIMEOUT) as client: | ||
client._session = None |
Oops, something went wrong.