Skip to content

test: stop the Orkney and Broxbourne tests failing on the calendar and the network - #2341

Merged
robbrad merged 1 commit into
masterfrom
claude/fix-time-bomb-tests
Nov 14, 2026
Merged

robbrad merged 1 commit into
masterfrom
claude/fix-time-bomb-tests

Conversation

@robbrad

@robbrad robbrad commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Why

The nightly Run Unit Tests job has failed on 12, 13 and 14 Nov (it was green until 11 Nov), and every open PR's unit-test check will now be red as well.

The cause is in a test I added in #2275, not in the product code. test_orkney_islands_council.py used hardcoded collection dates (21 Oct, 28 Oct, 11 Nov), and OrkneyIslandsCouncil correctly drops dates in the past. Once 11 Nov had passed, parse_data returned no bins and test_area_or_street_text_is_searched_and_first_address_looked_up failed (assert []).

It only surfaced now because the unit-test job used to ignore failures (fixed in #2273), so this is the gate doing its job, just 4 weeks after I wrote a time bomb into it.

Changes

No product code changes.

Test plan

  • Reproduced: with the clock frozen at 2026-11-12, the old Orkney test fails (1 failed, 3 passed), matching the nightly.
  • With the clock frozen at 2026-11-12, the new test passes (4 passed). It also passes at 2027-03-01.
  • I checked every other test I wrote in October for the same flaw. Only Orkney's depends on "now", because it is the only scraper under test that filters past dates; the rest use relative dates or parse without filtering.
  • make unit-tests on Python 3.14.10 with Home Assistant installed: 499 passed. The 3 failures are the known sandbox-only tests that need real network access (test_check_postcode_valid/_invalid, test_create_webdriver_local), which pass in CI.
  • This PR changes no council file, so CI will also run the full live suite; treat any failures there as the usual state of the nation, not regressions from this PR.

Merge with a test: title. It isn't a releasable commit type, so the bump workflow will skip cleanly.



Generated by Claude Code

Summary by CodeRabbit

  • Tests
    • Updated Broxbourne test setup to mock postcode validation.
    • Made Orkney collection-date tests relative to the current day and verified the expected upcoming dates.

…work

The nightly unit-test job has failed since 12 Nov. The Orkney fixture used
hardcoded collection dates (21 Oct, 28 Oct, 11 Nov), and the scraper drops
dates in the past, so once 11 Nov passed parse_data returned no bins and
test_area_or_street_text_is_searched_and_first_address_looked_up failed. It
only surfaced now because the unit-test job used to ignore failures. The
fixture dates are now relative to today. Reproduced with the clock frozen at
2026-11-12 (old test fails, new passes), and the new test also passes at
2027-03-01.

The Broxbourne error tests called api.postcodes.io through check_postcode
(a pure parsing test depending on a third-party API being up), so they are
stubbed offline, as was done for Tower Hamlets.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015MaCS29izthZp2dwtvLwf4
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Broxbourne test helper now stubs the postcode check. The Orkney tests now use dates relative to the current day and verify the expected collection dates.

Changes: Broxbourne test setup

Layer / File(s) Summary
Stub the postcode check
uk_bin_collection/tests/test_broxbourne_council.py
The test helper stubs check_postcode to return True and retains its existing browser-related mocks.

Orkney date tests

Layer / File(s) Summary
Use relative collection dates
uk_bin_collection/tests/test_orkney_islands_council.py
The tests create dates relative to the current day. The parsing test excludes the past collection and checks the remaining dates in ascending order. The search-flow test checks the exact expected dates.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Merge Risk: Minimal · up to 33cae

This change only updates tests, so product behavior is unaffected. It makes the Orkney tests stable over time and removes the Broxbourne tests' dependency on a third-party postcode service. Merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names both affected test files and the two causes of failure: the calendar-dependent Orkney dates and the network-dependent Broxbourne postcode check. The raw summary shows the changes are t…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names both affected test files and the two causes of failure: the calendar-dependent Orkney dates and the network-dependent Broxbourne postcode check. The raw summary shows the changes are test-only updates that mock the postcode check and make Orkney dates relative to today. The title is specific to the main change, so it passes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1c07aadd-d9d0-403c-ae74-8c0efe3d8381
Commits

Reviewing files that changed from the base of the PR and between 0d1b26a and 33cae1f.

Files selected for processing: 2

  • uk_bin_collection/tests/test_broxbourne_council.py
  • uk_bin_collection/tests/test_orkney_islands_council.py

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@codecov

codecov Bot commented Nov 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.57%. Comparing base (0d1b26a) to head (33cae1f).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2341   +/-   ##
=======================================
  Coverage   83.57%   83.57%           
=======================================
  Files          43       43           
  Lines        3380     3380           
=======================================
  Hits         2825     2825           
  Misses        555      555           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants