[PR #154] [MERGED] [tests] Cover post cache round-trip and content filters #158

Closed
opened 2026-10-13 19:48:08 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Glitchy-Sheep/boosty-downloader/pull/154
Author: @Glitchy-Sheep
Created: 8/16/2026
Status: ✅ Merged
Merged: 8/16/2026
Merged by: @Glitchy-Sheep

Base: main ← Head: test/cache-and-filter-units


📝 Commits (1)

  • c48b6a9 test: Cover post cache round-trip and content filters

📊 Changes

2 files changed (+234 additions, -0 deletions)

View changed files

➕ test/unit/post_caching/post_cache_test.py (+118 -0)
➕ test/unit/use_cases/should_execute_test.py (+116 -0)

📄 Description

[tests] Cover post cache round-trip and content filters

Summary

Second PR of the test safety-net stage (stacked on #153, merge that one first). The cache and the content-filter gate are exactly what the upcoming layering refactoring will move around - this pins their behavior first. Coverage of post_cache.py goes from 31% to 97%, total from 69% to 73%.

What is pinned

SQLite post cache (9 tests on tmp_path):

  • an unknown post needs every required part - a miss must not look like "already downloaded"
  • a fully cached post needs nothing, a partial one reports only the gap
  • an author edit (newer updated_at) invalidates every part
  • a second run extends the first: marking audio does not erase the files flag
  • state survives closing and reopening the database - every run is a new process
  • clean-cache really forgets everything and the database stays writable
  • a database with an outdated schema resets cleanly instead of crashing

Content-filter gate (10 tests):

  • the full 7x5 matrix: every chunk type answers only to its own filter
  • a post with no chunks is skipped, one missing part is enough to execute, no missing parts means skip

Known bug, documented as strict xfail

A cache file that is not SQLite at all (garbage bytes) crashes startup with DatabaseError: migrations in __init__ run before the corruption check, so the reinit path never gets a chance. The test asserts the desired contract (reset instead of crash) and is marked xfail(strict=True): today the run stays green, and the future fix will flip the test red until the mark is removed - a ready-made regression test.

Verification

  • task ci green: lint, format, pyright, 147 passed + 1 xfailed, build
  • task test:cov: post_cache.py 97%, models.py 91%, TOTAL 73%

Notes

  • No changelog entry: tests only, nothing changes for users (ci/skip-changelog)
  • Next PRs of the stage: golden tests for the mapper and HTML renderer, then local-server e2e + coverage gate

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Glitchy-Sheep/boosty-downloader/pull/154 **Author:** [@Glitchy-Sheep](https://github.com/Glitchy-Sheep) **Created:** 8/16/2026 **Status:** ✅ Merged **Merged:** 8/16/2026 **Merged by:** [@Glitchy-Sheep](https://github.com/Glitchy-Sheep) **Base:** `main` ← **Head:** `test/cache-and-filter-units` --- ### 📝 Commits (1) - [`c48b6a9`](https://github.com/Glitchy-Sheep/boosty-downloader/commit/c48b6a970f26a098d121d1412d2927564e97951b) test: Cover post cache round-trip and content filters ### 📊 Changes **2 files changed** (+234 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `test/unit/post_caching/post_cache_test.py` (+118 -0) ➕ `test/unit/use_cases/should_execute_test.py` (+116 -0) </details> ### 📄 Description # [tests] Cover post cache round-trip and content filters ## Summary Second PR of the test safety-net stage (stacked on #153, merge that one first). The cache and the content-filter gate are exactly what the upcoming layering refactoring will move around - this pins their behavior first. Coverage of `post_cache.py` goes from 31% to 97%, total from 69% to 73%. ## What is pinned **SQLite post cache** (9 tests on `tmp_path`): - an unknown post needs every required part - a miss must not look like "already downloaded" - a fully cached post needs nothing, a partial one reports only the gap - an author edit (newer `updated_at`) invalidates every part - a second run extends the first: marking audio does not erase the files flag - state survives closing and reopening the database - every run is a new process - `clean-cache` really forgets everything and the database stays writable - a database with an outdated schema resets cleanly instead of crashing **Content-filter gate** (10 tests): - the full 7x5 matrix: every chunk type answers only to its own filter - a post with no chunks is skipped, one missing part is enough to execute, no missing parts means skip ## Known bug, documented as strict xfail A cache file that is not SQLite at all (garbage bytes) crashes startup with `DatabaseError`: migrations in `__init__` run before the corruption check, so the reinit path never gets a chance. The test asserts the desired contract (reset instead of crash) and is marked `xfail(strict=True)`: today the run stays green, and the future fix will flip the test red until the mark is removed - a ready-made regression test. ## Verification - `task ci` green: lint, format, pyright, 147 passed + 1 xfailed, build - `task test:cov`: `post_cache.py` 97%, `models.py` 91%, TOTAL 73% ## Notes - No changelog entry: tests only, nothing changes for users (`ci/skip-changelog`) - Next PRs of the stage: golden tests for the mapper and HTML renderer, then local-server e2e + coverage gate --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-13 19:48:08 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Glitchy-Sheep/boosty-downloader#158
No description provided.