补齐证书齐备、证件折算、移动用证和合同绑定,并带上报销批量发放、付款备注以及个人开发流程升级,便于继续讨论已安排计划的调整规则。 Co-authored-by: Cursor <cursoragent@cursor.com>
46 lines
1.7 KiB
Python
46 lines
1.7 KiB
Python
"""menu badge: plan cert pending uses EXISTS count."""
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
from sqlalchemy import true
|
|
|
|
from app.services.pl_menu_badge_service import count_plan_cert_pending
|
|
from test_pl_quota_usage import case
|
|
from test_pl_quota_business import business
|
|
|
|
|
|
def test_count_plan_cert_pending_counts_conversion_plans_only():
|
|
db = MagicMock()
|
|
query = MagicMock()
|
|
db.query.return_value = query
|
|
query.filter.return_value = query
|
|
query.exists.return_value = true()
|
|
query.all.return_value = [('p1',), ('p2',)]
|
|
|
|
user = MagicMock()
|
|
with patch("app.services.pl_menu_badge_service.apply_pl_scope", side_effect=lambda q, *a, **k: q), \
|
|
patch("app.services.pl_quota_conversion.plans_needing_unit_conversion", return_value={'p1'}) as needing:
|
|
total = count_plan_cert_pending(db, "shanxia2.0", user)
|
|
|
|
assert total == 1
|
|
needing.assert_called_once()
|
|
assert needing.call_args.args[2] == ['p1', 'p2']
|
|
query.count.assert_not_called()
|
|
|
|
|
|
def test_legal_document_badge_is_independent_and_includes_archived_plan(business):
|
|
from app.services.pl_menu_badge_service import count_legal_use_document_pending
|
|
c = business
|
|
product = c.db.get(c.models.PlPlanProduct, 'pp')
|
|
product.is_toxic = 0
|
|
product.is_explosive = 1
|
|
c.plan.archive_status = 'archived'
|
|
c.plan.hazard_cert_ready = 1
|
|
c.db.flush()
|
|
assert count_legal_use_document_pending(c.db, 't', c.user) == 1
|
|
assert count_plan_cert_pending(c.db, 't', c.user) == 0
|
|
assert count_legal_use_document_pending(c.db, 'foreign', c.user) == 0
|
|
product.legal_use_cert_url = 'existing-document'
|
|
c.db.flush()
|
|
assert count_legal_use_document_pending(c.db, 't', c.user) == 0
|