23 lines
710 B
Python
23 lines
710 B
Python
"""menu badge: plan cert pending uses EXISTS count."""
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
from app.services.pl_menu_badge_service import count_plan_cert_pending
|
|
|
|
|
|
def test_count_plan_cert_pending_uses_sql_count_not_python_scan():
|
|
db = MagicMock()
|
|
query = MagicMock()
|
|
db.query.return_value = query
|
|
query.filter.return_value = query
|
|
query.count.return_value = 4
|
|
|
|
user = MagicMock()
|
|
with patch("app.services.pl_menu_badge_service.apply_pl_scope", side_effect=lambda q, *a, **k: q):
|
|
total = count_plan_cert_pending(db, "shanxia2.0", user)
|
|
|
|
assert total == 4
|
|
query.count.assert_called_once()
|
|
query.all.assert_not_called()
|