fix: cleanup codebase and sync SPEC with actual permissions
Phase 1: Ruff lint fixes - Remove unused imports across all files - Remove unused variables (now_utc, tz, ctx) - Fix f-string without placeholders - Fix E402 import order with noqa comments Phase 2: Remove confusing hard delete from storage - Removed delete_bounty() from RoomStorage Protocol (never used by app) - Removed delete_bounty() from JsonFileRoomStorage (was hard delete) - Removed corresponding tests (hard delete was never used) Phase 3: Sync SPEC.md with actual code behavior - Updated overview: admins can add/edit/delete (not 'anyone' + 'creator') - Updated command table: /add, /edit, /delete are admin only - Updated error handling messages Test results: 96 passed (2 hard delete tests removed)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
"""Tests for core/ports.py — storage interfaces."""
|
||||
|
||||
import pytest
|
||||
|
||||
from core.models import Bounty, RoomData, TrackingData, TrackedBounty
|
||||
from core.ports import RoomStorage, TrackingStorage
|
||||
@@ -35,12 +34,6 @@ class SimpleRoomStorage:
|
||||
self._rooms[room_id].bounties[i] = bounty
|
||||
break
|
||||
|
||||
def delete_bounty(self, room_id: int, bounty_id: int) -> None:
|
||||
if room_id in self._rooms:
|
||||
self._rooms[room_id].bounties = [
|
||||
b for b in self._rooms[room_id].bounties if b.id != bounty_id
|
||||
]
|
||||
|
||||
def get_bounty(self, room_id: int, bounty_id: int) -> Bounty | None:
|
||||
if room_id in self._rooms:
|
||||
for b in self._rooms[room_id].bounties:
|
||||
@@ -120,12 +113,6 @@ class MockRoomStorage:
|
||||
self._rooms[room_id].bounties[i] = bounty
|
||||
break
|
||||
|
||||
def delete_bounty(self, room_id: int, bounty_id: int) -> None:
|
||||
if room_id in self._rooms:
|
||||
self._rooms[room_id].bounties = [
|
||||
b for b in self._rooms[room_id].bounties if b.id != bounty_id
|
||||
]
|
||||
|
||||
def get_bounty(self, room_id: int, bounty_id: int) -> Bounty | None:
|
||||
if room_id in self._rooms:
|
||||
for b in self._rooms[room_id].bounties:
|
||||
@@ -243,19 +230,6 @@ class TestRoomStorage:
|
||||
assert result is not None
|
||||
assert result.text == "Updated"
|
||||
|
||||
def test_delete_bounty(self):
|
||||
storage = MockRoomStorage()
|
||||
bounty = Bounty(
|
||||
id=1,
|
||||
text="Test",
|
||||
link=None,
|
||||
due_date_ts=None,
|
||||
created_at=0,
|
||||
created_by_user_id=123,
|
||||
)
|
||||
storage.add_bounty(-1001, bounty)
|
||||
storage.delete_bounty(-1001, 1)
|
||||
assert storage.get_bounty(-1001, 1) is None
|
||||
|
||||
|
||||
class TestTrackingStorage:
|
||||
|
||||
Reference in New Issue
Block a user