fix: keep disabled unused packages manageable
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
from tracker import UsageTracker
|
||||
|
||||
|
||||
class _Mapper:
|
||||
def __init__(self, mapping=()):
|
||||
self.mapping = dict(mapping)
|
||||
|
||||
def get_package(self, class_type):
|
||||
return self.mapping.get(class_type, "__unknown__")
|
||||
|
||||
def get_all_packages(self):
|
||||
return set(self.mapping.values()) - {"__builtin__"}
|
||||
|
||||
|
||||
def test_never_used_disabled_package_stays_visible_for_enable(tmp_path):
|
||||
tracker = UsageTracker(db_path=str(tmp_path / "test.db"))
|
||||
|
||||
stats = tracker.get_package_stats(
|
||||
_Mapper(), disabled_packages={"VAE-Decode-PlusPlus"}
|
||||
)
|
||||
|
||||
assert stats == [{
|
||||
"package": "VAE-Decode-PlusPlus",
|
||||
"total_executions": 0,
|
||||
"used_nodes": 0,
|
||||
"nodes": [],
|
||||
"last_seen": None,
|
||||
"total_nodes": 0,
|
||||
"installed": False,
|
||||
"status": "uninstalled",
|
||||
"whitelisted": False,
|
||||
}]
|
||||
|
||||
|
||||
def test_disabled_entry_does_not_override_an_active_package(tmp_path):
|
||||
tracker = UsageTracker(db_path=str(tmp_path / "test.db"))
|
||||
|
||||
stats = tracker.get_package_stats(
|
||||
_Mapper({"Node": "VAE-Decode-PlusPlus"}),
|
||||
disabled_packages={"vae-decode-plusplus"},
|
||||
)
|
||||
|
||||
assert len(stats) == 1
|
||||
assert stats[0]["package"] == "VAE-Decode-PlusPlus"
|
||||
assert stats[0]["installed"] is True
|
||||
Reference in New Issue
Block a user