Added missing documentation to the global variables and class and object properties.

This commit is contained in:
依瑪貓 2023-06-08 17:20:24 +08:00
parent bc888195ad
commit 877f02fe82
2 changed files with 19 additions and 4 deletions

View File

@ -29,8 +29,11 @@ from werkzeug.datastructures import WWWAuthenticate, Authorization
from flask_digest_auth import DigestAuth, make_password_hash, Client
_REALM: str = "testrealm@host.com"
"""The realm."""
_USERNAME: str = "Mufasa"
"""The username."""
_PASSWORD: str = "Circle Of Life"
"""The password."""
class User:
@ -43,9 +46,11 @@ class User:
:param password: The clear-text password.
"""
self.username: str = username
self.password_hash: str = make_password_hash(
_REALM, username, password)
"""The username."""
self.password_hash: str = make_password_hash(_REALM, username, password)
"""The password hash."""
self.visits: int = 0
"""The number of visits."""
class AuthenticationTestCase(TestCase):
@ -68,6 +73,7 @@ class AuthenticationTestCase(TestCase):
auth: DigestAuth = DigestAuth()
auth.init_app(app)
self.user: User = User(_USERNAME, _PASSWORD)
"""The user account."""
user_db: Dict[str, User] = {_USERNAME: self.user}
@auth.register_get_password

View File

@ -29,8 +29,11 @@ from werkzeug.datastructures import WWWAuthenticate, Authorization
from flask_digest_auth import DigestAuth, make_password_hash, Client
_REALM: str = "testrealm@host.com"
"""The realm."""
_USERNAME: str = "Mufasa"
"""The username."""
_PASSWORD: str = "Circle Of Life"
"""The password."""
class User:
@ -43,11 +46,15 @@ class User:
:param password: The clear-text password.
"""
self.username: str = username
self.password_hash: str = make_password_hash(
_REALM, username, password)
"""The username."""
self.password_hash: str = make_password_hash(_REALM, username, password)
"""The password hash."""
self.visits: int = 0
"""The number of visits."""
self.is_active: bool = True
"""True if the account is active, or False otherwise."""
self.is_anonymous: bool = False
"""True if the account is anonymous, or False otherwise."""
def get_id(self) -> str:
"""Returns the username.
@ -86,6 +93,7 @@ class FlaskLoginTestCase(TestCase):
app.test_client_class = Client
self.has_flask_login: bool = True
"""Whether the Flask-Login package is installed."""
try:
import flask_login
except ModuleNotFoundError:
@ -99,6 +107,7 @@ class FlaskLoginTestCase(TestCase):
auth.init_app(app)
self.user: User = User(_USERNAME, _PASSWORD)
"""The user account."""
user_db: Dict[str, User] = {_USERNAME: self.user}
@auth.register_get_password