aurweb/aurweb/testing/requests.py
Kevin Morris 9052688ed2 add aurweb.time module
This module includes timezone-based utilities for a FastAPI request.
This commit introduces use of the AURTZ cookie within get_request_timezone.
This cookie should be set to the user or session's timezone.

* `make_context` has been modified to parse the request's timezone
  and include the "timezone" and "timezones" variables, along with
  a timezone specified "now" date.
+ Added `Timezone` attribute to aurweb.testing.requests.Request.user.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 20:11:17 -07:00

28 lines
626 B
Python

import aurweb.config
class User:
""" A fake User model. """
# Fake columns.
LangPreference = aurweb.config.get("options", "default_lang")
Timezone = aurweb.config.get("options", "default_timezone")
# A fake authenticated flag.
authenticated = False
def is_authenticated(self):
return self.authenticated
class Client:
""" A fake FastAPI Request.client object. """
# A fake host.
host = "127.0.0.1"
class Request:
""" A fake Request object which mimics a FastAPI Request for tests. """
client = Client()
cookies = dict()
headers = dict()
user = User()