ai-legal-assistant/backend/tests/unit/test_user_model.py
root 656f596d7e feat: implement AI legal assistant system MVP
Core modules:
- Laws: CRUD, search, AI-powered QA
- Analysis: legal research and case management
- Contracts: lifecycle management with templates
- Signatures: electronic signature workflow

Infrastructure:
- FastAPI + SQLite + async SQLAlchemy
- Docker deployment support
- 54 unit tests passing

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-01 03:34:44 +08:00

53 lines
1.5 KiB
Python

"""Unit tests for User model."""
import pytest
from datetime import datetime
from app.models.user import User, UserRole
class TestUserModel:
"""Test cases for User model."""
def test_user_creation(self):
"""Test creating a user instance."""
user = User(
username="testuser",
email="test@example.com",
hashed_password="hashed_password",
role=UserRole.LAWYER,
)
assert user.username == "testuser"
assert user.email == "test@example.com"
assert user.hashed_password == "hashed_password"
assert user.role == UserRole.LAWYER
assert user.is_active is True
def test_user_role_enum(self):
"""Test user role enum values."""
assert UserRole.ADMIN.value == "admin"
assert UserRole.LAWYER.value == "lawyer"
assert UserRole.REVIEWER.value == "reviewer"
assert UserRole.CLIENT.value == "client"
def test_user_default_values(self):
"""Test user default values."""
user = User(
username="testuser",
email="test@example.com",
hashed_password="hashed_password",
)
assert user.role == UserRole.CLIENT
assert user.is_active is True
def test_user_repr(self):
"""Test user string representation."""
user = User(
username="testuser",
email="test@example.com",
hashed_password="hashed_password",
)
assert "testuser" in repr(user)