[loop-generated] [test] Add unit tests for memory/crud.py — 395 lines untested #1344

Closed
opened 2026-03-24 02:47:58 +00:00 by Timmy · 2 comments
Owner

Problem

src/timmy/memory/crud.py has 395 lines with no corresponding test file. Memory CRUD operations are critical to Timmy's chain memory — bugs here can corrupt state.

Acceptance Criteria

  • Create tests/timmy/test_memory_crud.py
  • Cover all CRUD operations (create, read, update, delete)
  • Cover edge cases (missing records, duplicate keys)
  • All tests pass with tox -e unit
  • Tests are marked @pytest.mark.unit

Files

  • src/timmy/memory/crud.py (target)
  • tests/timmy/test_memory_crud.py (new)
## Problem `src/timmy/memory/crud.py` has 395 lines with no corresponding test file. Memory CRUD operations are critical to Timmy's chain memory — bugs here can corrupt state. ## Acceptance Criteria - [ ] Create `tests/timmy/test_memory_crud.py` - [ ] Cover all CRUD operations (create, read, update, delete) - [ ] Cover edge cases (missing records, duplicate keys) - [ ] All tests pass with `tox -e unit` - [ ] Tests are marked `@pytest.mark.unit` ## Files - `src/timmy/memory/crud.py` (target) - `tests/timmy/test_memory_crud.py` (new)
kimi was assigned by Timmy 2026-03-24 02:48:12 +00:00
Author
Owner

Kimi Instructions

  1. Read src/timmy/memory/crud.py to understand public API
  2. Create tests/timmy/test_memory_crud.py with unit tests covering core functions
  3. Every test must be marked @pytest.mark.unit
  4. Mock all external dependencies (DB, network, file I/O)
  5. Run tox -e unit to verify all tests pass
  6. Branch: kimi/issue-1344
  7. Open PR referencing this issue

Keep tests focused — test behavior, not implementation details.

## Kimi Instructions 1. Read `src/timmy/memory/crud.py` to understand public API 2. Create `tests/timmy/test_memory_crud.py` with unit tests covering core functions 3. Every test must be marked `@pytest.mark.unit` 4. Mock all external dependencies (DB, network, file I/O) 5. Run `tox -e unit` to verify all tests pass 6. Branch: `kimi/issue-1344` 7. Open PR referencing this issue Keep tests focused — test behavior, not implementation details.
Collaborator

PR #1358 created with comprehensive unit tests for memory/crud.py.

Summary

Created tests/timmy/test_memory_crud.py with 47 new test methods covering:

Core CRUD Operations

  • store_memory: basic storage, all fields, embedding on/off
  • delete_memory: existing/nonexistent/multiple
  • search_memories: empty db, filters, limits, relevance
  • get_memory_stats: empty/with entries, model status

Helper Functions

  • _build_search_filters: no filters, single/multiple criteria
  • _fetch_memory_candidates: with data, limits, WHERE clauses
  • _row_to_entry: basic conversion, JSON parsing
  • _score_and_filter: empty, relevance, keyword fallback

Personal Facts & Reflections

  • recall_personal_facts: with/without agent filter
  • recall_personal_facts_with_ids: ID + content
  • store_personal_fact: basic storage
  • update_personal_fact: existing/nonexistent
  • store_last_reflection: replace behavior, empty handling
  • recall_last_reflection: existing/none

Maintenance

  • prune_memories: empty, old, keep_facts flag
  • get_memory_context: empty, results, token limits

Edge Cases

  • Unicode, special characters, long content
  • Nested metadata, duplicate keys

All 966 tests pass.

PR #1358 created with comprehensive unit tests for `memory/crud.py`. ## Summary Created `tests/timmy/test_memory_crud.py` with 47 new test methods covering: ### Core CRUD Operations - `store_memory`: basic storage, all fields, embedding on/off - `delete_memory`: existing/nonexistent/multiple - `search_memories`: empty db, filters, limits, relevance - `get_memory_stats`: empty/with entries, model status ### Helper Functions - `_build_search_filters`: no filters, single/multiple criteria - `_fetch_memory_candidates`: with data, limits, WHERE clauses - `_row_to_entry`: basic conversion, JSON parsing - `_score_and_filter`: empty, relevance, keyword fallback ### Personal Facts & Reflections - `recall_personal_facts`: with/without agent filter - `recall_personal_facts_with_ids`: ID + content - `store_personal_fact`: basic storage - `update_personal_fact`: existing/nonexistent - `store_last_reflection`: replace behavior, empty handling - `recall_last_reflection`: existing/none ### Maintenance - `prune_memories`: empty, old, keep_facts flag - `get_memory_context`: empty, results, token limits ### Edge Cases - Unicode, special characters, long content - Nested metadata, duplicate keys All 966 tests pass.
kimi closed this issue 2026-03-24 03:08:37 +00:00
Sign in to join this conversation.
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1344