test: add comprehensive unit test suite
- Add tests/ directory with pytest configuration - Add conftest.py with database fixtures (test_db, sample data) - Add test_core.py: 21 tests for core operations (tablet, user, loan CRUD) - Add test_edge_cases.py: 14 tests for edge cases (duplicates, invalid IDs, etc.) - Add test_minimal_app.py: 11 tests for actual application functions - Update pyproject.toml with pytest and coverage configuration - Total: 46 tests covering core functionality and edge cases Tests cover: - Tablet CRUD operations - User CRUD operations - Loan/return workflows - Duplicate prevention (serial numbers, identifications) - Invalid ID handling - Already loaned device prevention - Non-existent loan handling - Multiple loans per user (one-to-many relationship) - Non-loanable device CRUD operations To run: python3 -m pytest tests/ -v
This commit is contained in:
parent
d3d1fb1b32
commit
83ac67fea2
7 changed files with 1575 additions and 0 deletions
|
|
@ -5,3 +5,33 @@ description = "Add your description here"
|
|||
readme = "README.md"
|
||||
requires-python = ">=3.14"
|
||||
dependencies = []
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
testpaths = ["tests"]
|
||||
python_files = "test_*.py"
|
||||
python_classes = "Test*"
|
||||
python_functions = "test_*"
|
||||
verbose = 1
|
||||
addopts = "-v"
|
||||
|
||||
[tool.coverage.run]
|
||||
source = ["."]
|
||||
omit = [
|
||||
"*/tests/*",
|
||||
"*/.venv/*",
|
||||
"*/__pycache__/*",
|
||||
"*/.git/*",
|
||||
"*/templates/*",
|
||||
]
|
||||
|
||||
[tool.coverage.report]
|
||||
exclude_lines = [
|
||||
"pragma: no cover",
|
||||
"def __repr__",
|
||||
"raise NotImplementedError",
|
||||
"if __name__ == .__main__.:",
|
||||
"if TYPE_CHECKING:",
|
||||
]
|
||||
|
||||
[tool.coverage.html]
|
||||
directory = "htmlcov"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue