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>
116 lines
3.6 KiB
Python
116 lines
3.6 KiB
Python
"""Unit tests for remaining models and services."""
|
|
import pytest
|
|
from datetime import date, datetime
|
|
|
|
from app.models.analysis import LegalAnalysis, Case, AnalysisStatus
|
|
from app.models.case import CaseReview, ReviewStatus, ReviewType
|
|
from app.models.contract import Contract, ContractTemplate, ContractStatus
|
|
from app.models.signature import SignatureRequest, Signature, SignatureStatus
|
|
|
|
|
|
class TestAnalysisModel:
|
|
"""Test cases for Analysis model."""
|
|
|
|
def test_legal_analysis_creation(self):
|
|
"""Test creating a legal analysis instance."""
|
|
analysis = LegalAnalysis(
|
|
user_id=1,
|
|
title="合同纠纷分析",
|
|
case_description="甲方未按合同约定支付货款...",
|
|
)
|
|
|
|
assert analysis.user_id == 1
|
|
assert analysis.title == "合同纠纷分析"
|
|
assert analysis.status == AnalysisStatus.DRAFT
|
|
|
|
def test_case_creation(self):
|
|
"""Test creating a case instance."""
|
|
case = Case(
|
|
title="买卖合同纠纷案",
|
|
case_number="(2024)京01民初1号",
|
|
court="北京市第一中级人民法院",
|
|
case_type="买卖合同纠纷",
|
|
)
|
|
|
|
assert case.title == "买卖合同纠纷案"
|
|
assert case.case_number == "(2024)京01民初1号"
|
|
|
|
|
|
class TestCaseReviewModel:
|
|
"""Test cases for CaseReview model."""
|
|
|
|
def test_case_review_creation(self):
|
|
"""Test creating a case review instance."""
|
|
review = CaseReview(
|
|
case_id=1,
|
|
reviewer_id=1,
|
|
review_type=ReviewType.INITIAL,
|
|
opinion="同意立案",
|
|
score=90,
|
|
)
|
|
|
|
assert review.case_id == 1
|
|
assert review.review_type == ReviewType.INITIAL
|
|
assert review.status == ReviewStatus.PENDING
|
|
|
|
|
|
class TestContractModel:
|
|
"""Test cases for Contract model."""
|
|
|
|
def test_contract_creation(self):
|
|
"""Test creating a contract instance."""
|
|
contract = Contract(
|
|
title="销售合同",
|
|
party_a="甲方公司",
|
|
party_b="乙方公司",
|
|
content="合同内容...",
|
|
created_by=1,
|
|
)
|
|
|
|
assert contract.title == "销售合同"
|
|
assert contract.party_a == "甲方公司"
|
|
assert contract.status == ContractStatus.DRAFT
|
|
|
|
def test_contract_template_creation(self):
|
|
"""Test creating a contract template instance."""
|
|
template = ContractTemplate(
|
|
name="标准销售合同模板",
|
|
content="模板内容...",
|
|
created_by=1,
|
|
contract_type="销售合同",
|
|
)
|
|
|
|
assert template.name == "标准销售合同模板"
|
|
assert template.contract_type == "销售合同"
|
|
|
|
|
|
class TestSignatureModel:
|
|
"""Test cases for Signature model."""
|
|
|
|
def test_signature_request_creation(self):
|
|
"""Test creating a signature request instance."""
|
|
request = SignatureRequest(
|
|
contract_id=1,
|
|
requester_id=1,
|
|
signer_name="张三",
|
|
signer_email="zhangsan@example.com",
|
|
token="abc123token",
|
|
expires_at=datetime.utcnow(),
|
|
)
|
|
|
|
assert request.contract_id == 1
|
|
assert request.signer_name == "张三"
|
|
assert request.status == SignatureStatus.PENDING
|
|
|
|
def test_signature_creation(self):
|
|
"""Test creating a signature instance."""
|
|
signature = Signature(
|
|
request_id=1,
|
|
signer_name="张三",
|
|
signature_data="base64encodedimage",
|
|
verification_hash="hash123",
|
|
)
|
|
|
|
assert signature.request_id == 1
|
|
assert signature.signer_name == "张三"
|