Files
Comfyui-Nodes-Stats/tests/test_classify.py
T
Ethanfel ba7f503e7d feat: disable unused packages via ComfyUI Manager
Add per-package and per-section "Disable" buttons on the Safe to Remove
and Consider Removing tiers. Uses ComfyUI Manager's queue API
(/customnode/installed, /manager/queue/disable|start|status) to move
packages into custom_nodes/.disabled, reconciling against Manager's
actual state and surfacing a restart banner. Hidden when Manager is
absent.

Also:
- tracker: extract shared _classify_age() recency helper (DRY), add tests
- js: centralize STATUS_META, replace inline hover handlers with CSS,
  de-duplicate summary bar
- bump version to 1.2.0, update README

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-21 10:36:19 +02:00

45 lines
1.3 KiB
Python

from datetime import datetime, timezone, timedelta
from tracker import _classify_age
def _thresholds():
now = datetime.now(timezone.utc)
return (
(now - timedelta(days=30)).isoformat(),
(now - timedelta(days=60)).isoformat(),
)
def _ago(days):
return (datetime.now(timezone.utc) - timedelta(days=days)).isoformat()
def test_recent_used():
one, two = _thresholds()
assert _classify_age(_ago(5), one, two, "used") == "used"
def test_recent_unused_new():
one, two = _thresholds()
assert _classify_age(_ago(5), one, two, "unused_new") == "unused_new"
def test_consider_removing_window():
one, two = _thresholds()
assert _classify_age(_ago(40), one, two, "used") == "consider_removing"
assert _classify_age(_ago(40), one, two, "unused_new") == "consider_removing"
def test_safe_to_remove_window():
one, two = _thresholds()
assert _classify_age(_ago(70), one, two, "used") == "safe_to_remove"
assert _classify_age(_ago(70), one, two, "unused_new") == "safe_to_remove"
def test_none_timestamp_is_recent():
one, two = _thresholds()
# No history yet -> treated as recent, never a removal candidate
assert _classify_age(None, one, two, "unused_new") == "unused_new"
assert _classify_age(None, one, two, "used") == "used"