-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move test client to
emmett-core
RSGI
- Loading branch information
Showing
14 changed files
with
81 additions
and
1,625 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
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,31 @@ | ||
from emmett_core.protocols.rsgi.test_client.client import EmmettTestClient as _EmmettTestClient, ClientContext as _ClientContext, ClientHTTPHandlerMixin | ||
|
||
from .ctx import current | ||
from .rsgi.handlers import HTTPHandler | ||
from .wrappers.response import Response | ||
|
||
|
||
class ClientContextResponse(Response): | ||
def __init__(self, original_response: Response): | ||
super().__init__() | ||
self.status = original_response.status | ||
self.headers._data.update(original_response.headers._data) | ||
self.cookies.update(original_response.cookies.copy()) | ||
self.__dict__.update(original_response.__dict__) | ||
|
||
|
||
class ClientContext(_ClientContext): | ||
_response_wrap_cls = ClientContextResponse | ||
|
||
def __init__(self, ctx): | ||
super().__init__(ctx) | ||
self.T = current.T | ||
|
||
|
||
class ClientHTTPHandler(ClientHTTPHandlerMixin, HTTPHandler): | ||
_client_ctx_cls = ClientContext | ||
|
||
|
||
class EmmettTestClient(_EmmettTestClient): | ||
_current = current | ||
_handler_cls = ClientHTTPHandler |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.