MIL-001 Project Foundation #23

Merged
Tirsvad merged 4 commits from mil-001-project-foundation into main 2026-10-14 15:22:05 +02:00
3 changed files with 81 additions and 0 deletions
Showing only changes of commit 7ba340a33a - Show all commits
+7
View File
@@ -0,0 +1,7 @@
"""@brief A Tkinter password manager that stores entries in a JSON file.
@file __init__.py
@package password_manager
"""
__version__ = "0.1.0"
+56
View File
@@ -0,0 +1,56 @@
"""@brief Constants of the password manager.
@file constants.py
@details Every literal that more than one module needs, or that a reader may
want to change, lives here and nowhere else.
"""
import string
from pathlib import Path
# Storage
DATA_FILE_NAME = "data.json" ##< Name of the JSON file that holds the entries.
DATA_FILE_PATH = Path(
DATA_FILE_NAME
) ##< Default location, relative to the working directory.
JSON_INDENT = 4 ##< Indentation of the written JSON, for readability.
KEY_EMAIL = "email" ##< JSON key of an entry's e-mail address.
KEY_PASSWORD = "password" ##< JSON key of an entry's password.
# Password generator
LETTERS = string.ascii_letters ##< Letters a password may use.
DIGITS = string.digits ##< Digits a password may use.
SYMBOLS = "!#$%&()*+" ##< Symbols a password may use.
MIN_LETTERS = 8 ##< Fewest letters in a generated password.
MAX_LETTERS = 10 ##< Most letters in a generated password.
MIN_SYMBOLS = 2 ##< Fewest symbols in a generated password.
MAX_SYMBOLS = 4 ##< Most symbols in a generated password.
MIN_DIGITS = 2 ##< Fewest digits in a generated password.
MAX_DIGITS = 4 ##< Most digits in a generated password.
# Window
WINDOW_TITLE = "Password Manager" ##< Title of the main window.
WINDOW_PADDING = 50 ##< Padding around the window content, in pixels.
LOGO_SIZE = 200 ##< Width and height of the logo canvas, in pixels.
DEFAULT_EMAIL = "name@example.com" ##< E-mail address the form starts with.
ENTRY_WIDTH_WIDE = 35 ##< Width in characters of the e-mail and add fields.
ENTRY_WIDTH_NARROW = 21 ##< Width in characters of the website and password fields.
# Labels and messages
LABEL_WEBSITE = "Website:"
LABEL_EMAIL = "Email/Username:"
LABEL_PASSWORD = "Password:"
BUTTON_SEARCH = "Search"
BUTTON_GENERATE = "Generate Password"
BUTTON_ADD = "Add"
TITLE_OOPS = "Oops"
TITLE_SAVED = "Saved"
TITLE_FOUND = "Found"
MESSAGE_EMPTY_FIELDS = "Please don't leave any fields empty!"
MESSAGE_NO_DATA_FILE = "No Data File Found."
MESSAGE_NO_DETAILS = "No details for {website} exists."
MESSAGE_CONFIRM_SAVE = (
"These are the details entered:\nEmail: {email}\n"
"Password: {password}\nIs it ok to save?"
)
MESSAGE_DETAILS = "Email: {email}\nPassword: {password}"
+18
View File
@@ -0,0 +1,18 @@
"""Smoke test: the package and its constants import and hold sane values."""
import password_manager
from password_manager import constants
def test_package_has_version() -> None:
assert password_manager.__version__
def test_data_file_name_is_json() -> None:
assert constants.DATA_FILE_NAME.endswith(".json")
def test_password_length_bounds_are_ordered() -> None:
assert constants.MIN_LETTERS <= constants.MAX_LETTERS
assert constants.MIN_SYMBOLS <= constants.MAX_SYMBOLS
assert constants.MIN_DIGITS <= constants.MAX_DIGITS