chore(tests): replace synthetic s1/sub1 subscription_id literals with real UUIDs in test fixtures

Open Beginner friendly
#5,634 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
testing

Research direction

Start in tests/news/test_flask_api_deep_coverage.py and review the listed subscription test fixtures, URLs, and mock assertions. Run the focused pytest file and pre-commit for that file after the mechanical fixture migration. Done means the valid UUID constant is used consistently, exact assertions remain intact, and the specified searches find no remaining synthetic subscription IDs.

Written by the indexing model from the issue text.

Description

maintenance

Summary

Several news-route coverage tests use s1 and sub1 as fake subscription IDs. PR #5603 already forced one fix on get_news_feed; #5627 will force another on get_subscription_history. Future guards on any other subscription_id-bearing route will collide with the same fixtures. Migrate the synthetic literals to real UUIDs proactively so the next guard lands without test-fixture churn.

Evidence

grep -nE '/s1|subscription_id.*=|"s1"' tests/news/test_flask_api_deep_coverage.py on the pre-#5603 tree surfaces the following occurrences:

Line Class / test Synthetic literal
132, 142 TestGetNewsFeed.test_with_query_params sub1 (request URL + mock assertion) — already migrated in commit 517331e8c via PR #5603 fix
638 TestCreateSubscription mock fixture {"id": "s1", "query": "AI"}
700, 710, 713, 714 TestGetSubscription.test_returns_subscription URL /subscriptions/s1, body id == "s1", mock assertion "s1"
757 TestGetSubscription.test_404_not_found URL /subscriptions/s1
771, 782, 791 TestUpdateSubscription.test_updates_successfully mock result {id: "s1"}, URL, call_args check
799, 810 TestUpdateSubscription.test_… (second scenario) URL /subscriptions/s1
854, 865 TestUpdateSubscription set up URL /subscriptions/s1
891, 895, 896, 923 TestDeleteSubscription URL /subscriptions/s1, message check "s1" in data["message"], mock assertion
956, 960 TestGetSubscriptionHistory.test_returns_history URL …/s1/history, mock_hist.assert_called_once_with("s1", 20) — will be migrated under #5627
979, 982 TestGetSubscriptionHistory.test_custom_limit URL …/s1/history?limit=5, mock_hist.assert_called_once_with("s1", 5) — will be migrated under #5627
1000 TestGetSubscriptionHistory.test_error_in_result URL …/s1/history — will be migrated under #5627
1410, 1421 TestGetUserSubscriptions-style list body assertions list entries {id: "s1", query_or_topic: "AI"} and assertion data["Work"] == [{id: "s1", …}]

Why this is worth doing now

  • #5627 will require migrating the three history-row calls; doing them in isolation leaves s1 brittle for every other route's future guard.
  • Every s1 literal in a URL path or mock assertion will be the first thing any new validator trips; the same refresh would recur.
  • One mechanical pass keeps the diff small and easy to review.

Proposed change

Mechanical fixture migration only. No production-code change.

  • Replace every synthetic s1 and sub1 in tests/news/test_flask_api_deep_coverage.py with a single fixed valid UUID literal, e.g. 11111111-1111-4111-8111-111111111111 (mirroring PR #5603).

  • Update mock fixtures ({"id": "s1", …}) and assertions (mock_X.assert_called_once_with("s1", …)) to use the UUID consistently.

  • Inside tests/news/test_flask_api_deep_coverage.py, introduce a single module-level constant:

    _TEST_SUB_ID = "11111111-1111-4111-8111-111111111111"
    

    and reference it everywhere s1 would have gone. Keeps the migrations trivially greppable and future migrations a one-line change.

Acceptance criteria

  • grep -nE '/s1|subscription_id.*=|"s1"' tests/news/test_flask_api_deep_coverage.py returns no matches except those already migrated by PR #5603.
  • No test assertion weakened (e.g., do not switch from exact equality to substring / in).
  • pytest tests/news/test_flask_api_deep_coverage.py -q is green in the repo venv (Python 3.12) and via the project's Docker test image.
  • pre-commit run --files tests/news/test_flask_api_deep_coverage.py is green.
  • Search for s1/sub1 across tests/ shows no other surprising subscription_id occurrences.

Out of scope

  • Any production-code guard addition (covered by #5627 and future issues).
  • Changing test class names, fixtures, or assertion structure beyond the literal swap.
  • Any other test file that uses s1 for unrelated reasons (e.g., a search query, a subscription topic) — those remain as-is.

References

  • PR #5603 — original sub1 → UUID migration in TestGetNewsFeed.test_with_query_params (commit 517331e8c). Same diff shape is being generalized here.
  • Issue #5627 — adds the same fixture migration for the history route; this issue fills in every other call site so #5627 only needs to cover the history rows.
  • File: tests/news/test_flask_api_deep_coverage.py.

Estimated complexity

Small. Mechanical edit, ~25 minute budget. No schema or contract change.

Dominant language
Python
Stars
9.1k
Forks
824
Avg merge
3d 4h
Merged PRs (30d)
289

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from LearningCircuit/local-deep-research

All issues in LearningCircuit/local-deep-research

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.