"""Unit tests for the User model.""" from __future__ import annotations import pytest {% if cookiecutter.use_auth == "yes" %} from {{ cookiecutter.project_name }}.services.auth_service import AuthService def test_hash_password_is_not_plain() -> None: """hash_password must not store the plain text.""" hashed = AuthService.hash_password("mypassword") assert hashed != "mypassword" assert hashed.startswith("$2") # bcrypt prefix def test_verify_password_roundtrip() -> None: """verify_password must accept the correct password.""" hashed = AuthService.hash_password("mypassword") assert AuthService.verify_password("mypassword", hashed) is True assert AuthService.verify_password("wrong", hashed) is False {% else %} def test_user_model_table_name() -> None: """User model must use the 'users' table.""" from {{ cookiecutter.project_name }}.db.models.user import User assert User._meta.db_table == "users" {% endif %}