Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused error-handling change is correct and adequately covered by tests.
Pull request overview
Adds privacy-view coverage for Issue #12978 and returns HTTP 404 when the privacy document is unavailable.
Changes:
- Handles missing privacy documents consistently with class-based legal views.
- Tests document processing, locale handling, templates, and missing-document behavior.
- Reviewed using the repository’s custom instructions and
AGENTS.md; no material risks or follow-ups found.
File summaries
| File | Description |
|---|---|
bedrock/privacy/views.py |
Raises Http404 for a missing privacy policy. |
bedrock/privacy/tests/test_views.py |
Adds comprehensive privacy-view tests. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #17383 +/- ##
==========================================
+ Coverage 83.36% 83.54% +0.17%
==========================================
Files 177 177
Lines 9318 9321 +3
==========================================
+ Hits 7768 7787 +19
+ Misses 1550 1534 -16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
janriokrause
left a comment
There was a problem hiding this comment.
Thanks for the fix and the coverage! Looks good! A few tiny suggestions to trim the tests and add one:
- Drop
TestPrivacyDocView.test_missing_doc_gives_404. The 404 lives inLegalDocView, whichPrivacyDocViewdoesn't override, and it's already covered bytest_missing_doc_is_404inbedrock/legal_docs/tests/test_base.py. The test that matters forPrivacyDocViewistest_missing_doc_is_passed_through, since it covers theNoneguard. - Merge
test_active_locales_are_left_aloneintotest_content_is_processed. Both build the same doc, so one extra assert covers it. - Drop
test_doc_is_loaded_for_the_request_locale.test_renders_processed_docalready asserts theload_legal_doccall, and switching the locale todedoesn't hit a different code path. - Slim down
TestProcessLegalDoc:- Combine the http/https tests. They exercise the same regex (
https?). - Drop
test_external_links_are_untouched. It's covered bytest_every_matching_link_is_rewritten. - Keep only one of
test_returns_a_soup_object/test_doc_without_links_is_returned_unchanged. Both just check that the HTML parses. - Drop
test_rewrite_is_not_limited_to_anchors. It locks in incidental behavior, and legal docs come from Markdown, so<link>tags won't show up.
- Combine the http/https tests. They exercise the same regex (
- Move the preview
?v=producttest intoTestFirefoxPrivacyNextViewBehaviour, so all the preview view tests live in one place. - Add an unmocked regression test for the actual bug. The existing 404 tests mock
load_legal_doc, but this one goes through the real URL routing and lookup, and it returns a 500 onmain:
def test_missing_doc_gives_404_end_to_end(self):
# The test DB has no `LegalDoc` rows, so `load_legal_doc` returns `None` without mocking
resp = self.client.get("/en-US/privacy/")
assert resp.status_code == 404|
TY!! :) |
|
Sure, take your time. Please keep in mind that many of our developers have limited availability because of an engineering summit taking place all next week. I'll come back to your PRs after the summit 😊. |
|
Ofc np :) |
bedrock/privacy/views.pyprivacy()returning a 500 when the privacy doc is missing from the database (now raisesHttp404, like the class-based views already did)Linked to Issue #12978