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>
71 lines
2.3 KiB
Python
71 lines
2.3 KiB
Python
"""Unit tests for Law model."""
|
|
import pytest
|
|
from datetime import date
|
|
|
|
from app.models.law import Law, LawArticle, LawType, LawStatus
|
|
|
|
|
|
class TestLawModel:
|
|
"""Test cases for Law model."""
|
|
|
|
def test_law_creation(self):
|
|
"""Test creating a law instance."""
|
|
law = Law(
|
|
title="中华人民共和国民法典",
|
|
law_type=LawType.LAW,
|
|
promulgation_date=date(2020, 5, 28),
|
|
effective_date=date(2021, 1, 1),
|
|
status=LawStatus.EFFECTIVE,
|
|
issuing_authority="全国人民代表大会",
|
|
content="民法典全文...",
|
|
)
|
|
|
|
assert law.title == "中华人民共和国民法典"
|
|
assert law.law_type == LawType.LAW
|
|
assert law.promulgation_date == date(2020, 5, 28)
|
|
assert law.effective_date == date(2021, 1, 1)
|
|
assert law.status == LawStatus.EFFECTIVE
|
|
assert law.issuing_authority == "全国人民代表大会"
|
|
|
|
def test_law_type_enum(self):
|
|
"""Test law type enum values."""
|
|
assert LawType.LAW.value == "law"
|
|
assert LawType.REGULATION.value == "regulation"
|
|
assert LawType.RULE.value == "rule"
|
|
assert LawType.JUDICIAL_INTERPRETATION.value == "judicial_interpretation"
|
|
|
|
def test_law_status_enum(self):
|
|
"""Test law status enum values."""
|
|
assert LawStatus.EFFECTIVE.value == "effective"
|
|
assert LawStatus.REVOKED.value == "revoked"
|
|
assert LawStatus.AMENDED.value == "amended"
|
|
|
|
def test_law_default_values(self):
|
|
"""Test law default values."""
|
|
law = Law(
|
|
title="测试法规",
|
|
law_type=LawType.REGULATION,
|
|
promulgation_date=date(2024, 1, 1),
|
|
effective_date=date(2024, 2, 1),
|
|
issuing_authority="测试机关",
|
|
content="测试内容",
|
|
)
|
|
|
|
assert law.status == LawStatus.EFFECTIVE
|
|
|
|
|
|
class TestLawArticleModel:
|
|
"""Test cases for LawArticle model."""
|
|
|
|
def test_article_creation(self):
|
|
"""Test creating a law article instance."""
|
|
article = LawArticle(
|
|
law_id=1,
|
|
article_number="第一条",
|
|
content="为了保护民事主体的合法权益...",
|
|
)
|
|
|
|
assert article.law_id == 1
|
|
assert article.article_number == "第一条"
|
|
assert "民事主体" in article.content
|