From 67dd432e86a172927b5e54b2d9e7798115ca4555 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Fri, 31 Dec 2021 15:10:54 -0800 Subject: [PATCH] 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 --- aurweb/testing/requests.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/aurweb/testing/requests.py b/aurweb/testing/requests.py index 76f7afca..be13ab77 100644 --- a/aurweb/testing/requests.py +++ b/aurweb/testing/requests.py @@ -29,13 +29,17 @@ class URL: class Request: """ A fake Request object which mimics a FastAPI Request for tests. """ client = Client() - user = User() url = URL() def __init__(self, + user: User = User(), + authenticated: bool = False, method: str = "GET", headers: Dict[str, str] = dict(), cookies: Dict[str, str] = dict()) -> "Request": + self.user = user + self.user.authenticated = authenticated + self.method = method.upper() self.headers = headers self.cookies = cookies