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:
@@ -3,7 +3,6 @@
|
||||
import pytest
|
||||
from unittest.mock import patch, MagicMock
|
||||
from io import StringIO
|
||||
import sys
|
||||
|
||||
from core.models import Bounty
|
||||
from core.ports import RoomStorage, TrackingStorage
|
||||
@@ -237,7 +236,7 @@ class TestCLIValidation:
|
||||
main()
|
||||
mock_bounty_service.update_bounty.assert_called_once()
|
||||
call_kwargs = mock_bounty_service.update_bounty.call_args
|
||||
assert call_kwargs.kwargs.get("clear_link") == True
|
||||
assert call_kwargs.kwargs.get("clear_link") is True
|
||||
|
||||
def test_update_clear_due_flag(self):
|
||||
"""Test update with --clear-due flag."""
|
||||
@@ -255,7 +254,7 @@ class TestCLIValidation:
|
||||
main()
|
||||
mock_bounty_service.update_bounty.assert_called_once()
|
||||
call_kwargs = mock_bounty_service.update_bounty.call_args
|
||||
assert call_kwargs.kwargs.get("clear_due") == True
|
||||
assert call_kwargs.kwargs.get("clear_due") is True
|
||||
|
||||
|
||||
class TestCLIOutput:
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
|
||||
import json
|
||||
import os
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from config import Config, DEFAULT_DATA_DIR
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
"""Tests for adapters/storage/json_file.py — JSON file storage adapter."""
|
||||
|
||||
import json
|
||||
import os
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from adapters.storage.json_file import JsonFileRoomStorage, JsonFileTrackingStorage
|
||||
from core.models import Bounty, RoomData, TrackingData, TrackedBounty
|
||||
@@ -99,15 +97,6 @@ class TestJsonFileRoomStorage:
|
||||
|
||||
assert self.storage.load(-1001) is None
|
||||
|
||||
def test_delete_bounty(self):
|
||||
"""Test that delete_bounty removes a bounty."""
|
||||
bounty = self._create_bounty(id=1)
|
||||
self.storage.add_bounty(-1001, bounty)
|
||||
self.storage.delete_bounty(-1001, 1)
|
||||
|
||||
loaded = self.storage.load(-1001)
|
||||
assert len(loaded.bounties) == 0
|
||||
|
||||
def test_get_bounty_found(self):
|
||||
"""Test that get_bounty returns the bounty when found."""
|
||||
bounty = self._create_bounty(id=1)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
"""Tests for core/models.py — domain dataclasses."""
|
||||
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from core.models import (
|
||||
Bounty,
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
"""Tests for core/services.py — business logic services."""
|
||||
|
||||
import pytest
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from core.models import Bounty, RoomData, TrackingData, TrackedBounty
|
||||
from core.models import RoomData
|
||||
from core.services import BountyService, TrackingService
|
||||
from tests.test_ports import MockRoomStorage, MockTrackingStorage
|
||||
|
||||
|
||||
Reference in New Issue
Block a user