MIL-001: project foundation #32

Merged
Tirsvad merged 4 commits from mil-001-foundation into main 2026-11-06 05:22:53 +01:00
9 changed files with 86 additions and 0 deletions
Showing only changes of commit 6d1dfa9300 - Show all commits

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
## @file __init__.py
# @brief Root package of the Day 54 Flask lecture project.
"""Day 54 Flask lecture project, organised in layers."""
+3
View File
@@ -0,0 +1,3 @@
## @file __init__.py
# @brief Application layer: use cases and the ports they need.
"""Application layer: use cases and ports."""
+3
View File
@@ -0,0 +1,3 @@
## @file __init__.py
# @brief Domain layer: pure rules, no input or output, no framework.
"""Domain layer: pure rules with no framework and no input or output."""
+8
View File
@@ -0,0 +1,8 @@
## @file constants.py
# @brief Constants of the domain layer.
"""Constants of the domain layer."""
from typing import Final
## @brief The greeting shown by the first Flask route.
GREETING: Final[str] = "Hello, World!"
@@ -0,0 +1,3 @@
## @file __init__.py
# @brief Infrastructure layer: server settings and configuration.
"""Infrastructure layer: server settings and configuration."""
@@ -0,0 +1,20 @@
## @file constants.py
# @brief Constants of the infrastructure layer (server settings).
"""Server settings used by the entry point."""
from typing import Final
## @brief Interface the development server binds to.
HOST: Final[str] = "127.0.0.1"
## @brief TCP port of the development server.
PORT: Final[int] = 5000
## @brief Whether the development server runs in debug mode.
DEBUG: Final[bool] = True
## @brief Dotted module path of the Flask application.
APP_MODULE: Final[str] = "flask_day_54.presentation.hello"
## @brief Name of the environment variable Flask reads to find the application.
FLASK_APP_ENV_VAR: Final[str] = "FLASK_APP"
@@ -0,0 +1,3 @@
## @file __init__.py
# @brief Presentation layer: entry points, the Flask application.
"""Presentation layer: entry points and the Flask application."""
+13
View File
@@ -0,0 +1,13 @@
## @file test_domain_constants.py
# @brief Unit tests for the domain constants.
"""Unit tests for the domain constants."""
from flask_day_54.domain import constants
def test_greeting_has_expected_value() -> None:
assert constants.GREETING == "Hello, World!"
def test_greeting_is_not_empty() -> None:
assert constants.GREETING.strip() != ""
@@ -0,0 +1,30 @@
## @file test_infrastructure_constants.py
# @brief Unit tests for the infrastructure constants.
"""Unit tests for the infrastructure constants."""
from flask_day_54.infrastructure import constants
def test_host_is_loopback() -> None:
assert constants.HOST == "127.0.0.1"
def test_port_is_int_in_unprivileged_range() -> None:
assert isinstance(constants.PORT, int)
assert 1024 <= constants.PORT <= 65535
def test_port_has_expected_value() -> None:
assert constants.PORT == 5000
def test_debug_is_enabled() -> None:
assert constants.DEBUG is True
def test_app_module_points_to_presentation_hello() -> None:
assert constants.APP_MODULE == "flask_day_54.presentation.hello"
def test_flask_app_env_var_name() -> None:
assert constants.FLASK_APP_ENV_VAR == "FLASK_APP"