35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
"""当月核量号:按租户+创建年月自增,含软删占用。"""
|
|
from datetime import datetime
|
|
from unittest.mock import MagicMock
|
|
|
|
from app.crud import research_donation as crud
|
|
|
|
|
|
def test_allocate_monthly_verify_no_first_of_month():
|
|
db = MagicMock()
|
|
db.query.return_value.filter.return_value.order_by.return_value.first.return_value = (None,)
|
|
no = crud.allocate_monthly_verify_no(
|
|
db, tenant_no="zkxw", create_time=datetime(2025, 8, 15, 10, 0, 0)
|
|
)
|
|
assert no == "202508001"
|
|
|
|
|
|
def test_allocate_monthly_verify_no_increments():
|
|
db = MagicMock()
|
|
db.query.return_value.filter.return_value.order_by.return_value.first.return_value = (
|
|
"202508007",
|
|
)
|
|
no = crud.allocate_monthly_verify_no(
|
|
db, tenant_no="zkxw", create_time=datetime(2025, 8, 20, 12, 0, 0)
|
|
)
|
|
assert no == "202508008"
|
|
|
|
|
|
def test_allocate_monthly_verify_no_new_month_resets():
|
|
db = MagicMock()
|
|
db.query.return_value.filter.return_value.order_by.return_value.first.return_value = (None,)
|
|
no = crud.allocate_monthly_verify_no(
|
|
db, tenant_no="zkxw", create_time=datetime(2025, 9, 1, 9, 0, 0)
|
|
)
|
|
assert no == "202509001"
|