test(commands): add unit tests for command handlers
Add comprehensive unit tests for all command handlers: - TestHelperFunctions: is_group, get_group_id, get_user_id, get_room_id - TestCmdBounty: lists bounties, handles empty - TestCmdMy: shows tracked in groups, personal in DM - TestCmdAdd: add bounty success, validation - TestCmdUpdate: update bounty, permission denied, invalid ID - TestCmdDelete: delete bounty, invalid ID - TestCmdTrack: track in group, reject in DM - TestCmdUntrack: untrack in group, reject in DM - TestCmdStart: group vs DM behavior - TestCmdHelp: shows all commands Also fix conftest.py to remove obsolete fresh_db fixture that referenced non-existent db module. All 55 tests pass. Addresses han's feedback on PR #33
This commit is contained in:
@@ -6,22 +6,5 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
# Add the app directory to path so `import db` works when running pytest
|
||||
# Add the app directory to path so imports work when running pytest
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def fresh_db(monkeypatch):
|
||||
"""Replace DB_PATH with a temp file before any test runs."""
|
||||
import db as _db
|
||||
|
||||
tmp = tempfile.NamedTemporaryFile(suffix=".db", delete=False)
|
||||
tmp_path = Path(tmp.name)
|
||||
tmp.close()
|
||||
|
||||
monkeypatch.setattr(_db, "DB_PATH", tmp_path)
|
||||
_db.init_db()
|
||||
|
||||
yield tmp_path
|
||||
|
||||
tmp_path.unlink(missing_ok=True)
|
||||
|
||||
Reference in New Issue
Block a user