Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
ARTIFACT_DIR := $(if $(ARTIFACT_DIR),$(ARTIFACT_DIR),tests/test_results)
PATH_TO_PLANTUML := ~/bin


run: ## Run the service locally
python src/lightspeed-stack.py

test-unit: ## Run the unit tests
@echo "Running unit tests..."
@echo "Reports will be written to ${ARTIFACT_DIR}"
COVERAGE_FILE="${ARTIFACT_DIR}/.coverage.unit" pdm run pytest tests/unit --cov=src --cov-report term-missing --cov-report "json:${ARTIFACT_DIR}/coverage_unit.json" --junit-xml="${ARTIFACT_DIR}/junit_unit.xml" --cov-fail-under=60

test-integration: ## Run integration tests tests
@echo "Running integration tests..."
@echo "Reports will be written to ${ARTIFACT_DIR}"
COVERAGE_FILE="${ARTIFACT_DIR}/.coverage.integration" pdm run pytest tests/integration --cov=src --cov-report term-missing --cov-report "json:${ARTIFACT_DIR}/coverage_integration.json" --junit-xml="${ARTIFACT_DIR}/junit_integration.xml" --cov-fail-under=60

check-types: ## Checks type hints in sources
MYPYPATH=src pdm run mypy --namespace-packages --explicit-package-bases --strict --disallow-untyped-calls --disallow-untyped-defs --disallow-incomplete-defs .

Expand Down
13 changes: 11 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,17 @@ distribution = true

[dependency-groups]
dev = [
"black>=25.1.0"
]
"black>=25.1.0",
"pytest>=8.3.2",
"pytest-cov>=5.0.0",
]

[tool.pdm.scripts]
start = "pdm run make run"
test-unit = "pdm run make test-unit"
test-integration = "pdm run make test-integration"

[tool.pytest.ini_options]
pythonpath = [
"src"
]
8 changes: 8 additions & 0 deletions tests/unit/test_configuration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""Unit tests for functions defined in src/configuration.py."""

from src.configuration import configuration


def test_default_configuration():
cfg = configuration
assert cfg is not None
14 changes: 14 additions & 0 deletions tests/unit/test_log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""Unit tests for functions defined in src/log.py."""

from src.log import get_logger


def test_get_logger():
"""Check the function to retrieve logger."""
logger_name = "foo"
logger = get_logger(logger_name)
assert logger is not None
assert logger.name == logger_name

# at least one handler need to be set
assert len(logger.handlers) >= 1