mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat(testing.requests): add Request.__init__
This new constructor is a beginning to making Request a bit more easy to deal with for standard testing needs. With this commit, users can now specify a `user` and `authenticated` state while constructing a Request: request = Request(user=some_user, authenticated=True) By default, the `authenticated` kwarg is set to False and `user` is set to `aurweb.testing.requests.User()`. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
cab86035e9
commit
67dd432e86
1 changed files with 5 additions and 1 deletions
|
@ -29,13 +29,17 @@ class URL:
|
||||||
class Request:
|
class Request:
|
||||||
""" A fake Request object which mimics a FastAPI Request for tests. """
|
""" A fake Request object which mimics a FastAPI Request for tests. """
|
||||||
client = Client()
|
client = Client()
|
||||||
user = User()
|
|
||||||
url = URL()
|
url = URL()
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
|
user: User = User(),
|
||||||
|
authenticated: bool = False,
|
||||||
method: str = "GET",
|
method: str = "GET",
|
||||||
headers: Dict[str, str] = dict(),
|
headers: Dict[str, str] = dict(),
|
||||||
cookies: Dict[str, str] = dict()) -> "Request":
|
cookies: Dict[str, str] = dict()) -> "Request":
|
||||||
|
self.user = user
|
||||||
|
self.user.authenticated = authenticated
|
||||||
|
|
||||||
self.method = method.upper()
|
self.method = method.upper()
|
||||||
self.headers = headers
|
self.headers = headers
|
||||||
self.cookies = cookies
|
self.cookies = cookies
|
||||||
|
|
Loading…
Add table
Reference in a new issue