tests.test_pages_redirects module¶
Tests for the Cloudflare Pages _redirects engine replica.
Every behaviour asserted here was transcribed from the reference
implementation in cloudflare/workers-sdk, not from the documentation: the
budget accounting, the trailing-slash literalism, the order in which exact
rules and patterns are probed, and the rules dropped at run time are precisely
the parts the documentation does not state.
- tests.test_pages_redirects.test_statics_first_ride_the_static_budget()[source]¶
Exact rules ahead of the first dynamic one never touch the 100 budget.
- tests.test_pages_redirects.test_statics_after_a_dynamic_burn_the_dynamic_budget_until_the_file_dies()[source]¶
The undocumented kill switch: rule 101 of the mixed stream aborts the file.
Not “is skipped”: the parser breaks, so every remaining line is discarded and nothing in the deploy pipeline says so.
- tests.test_pages_redirects.test_misordered_statics_names_every_late_exact_rule()[source]¶
Each late exact rule is one slot of headroom lost, so each is reported.
- tests.test_pages_redirects.test_engine_refusals(line, fragment)[source]¶
Each refused shape is dropped with the engine’s own message.
- tests.test_pages_redirects.test_trailing_slashes_are_different_sources()[source]¶
/aand/a/never match each other; only the splat bridges them.
- tests.test_pages_redirects.test_splat_matches_the_bare_trailing_slash_through_an_empty_capture()[source]¶
/dir/*answers/dir/itself, the historically loaded WordPress case.
- tests.test_pages_redirects.test_an_exact_rule_wins_only_above_the_first_dynamic_rule(text, expected)[source]¶
The server’s map of exact sources holds the rules above the first pattern.
An exact rule below that point is probed in file order with the patterns, so a pattern above it that matches the same path answers first. The reference gives these two answers for these two files.
- tests.test_pages_redirects.test_shadowed_statics_pairs_each_dead_rule_with_the_pattern_that_answers()[source]¶
A late exact rule that a pattern above it matches never fires.
- tests.test_pages_redirects.test_a_source_that_cannot_compile_is_dropped_at_run_time(source, request_path)[source]¶
The parser keeps the rule, then the server fails to build its pattern.
The reference catches that error and drops the rule alone, so the rules around it keep working and nothing is reported.
- tests.test_pages_redirects.test_unresolved_names_what_stays_literal_in_a_destination(line, expected)[source]¶
The engine reports nothing for these: the visitor gets
:namein the URL.
- tests.test_pages_redirects.test_budget_constant_matches_the_reference()[source]¶
The number the whole accounting hangs on, pinned against typos.
- tests.test_pages_redirects.test_sample_path_concretizes_a_source(source, expected)[source]¶
Every sampled path must match the rule it was derived from.
- tests.test_pages_redirects.test_discarded_rules_recovers_the_abandoned_tail()[source]¶
What the engine never read, named with its real line numbers.
parse_redirectsreports only that it stopped, because that is all production does. Recovering the tail is what lets the lint say which URLs went dead rather than how many rules did.
- tests.test_pages_redirects.test_discarded_rules_is_empty_for_a_file_read_to_the_end()[source]¶
No abort, nothing abandoned: the common case costs no second parse.
- tests.test_pages_redirects.test_an_abandoned_source_can_be_captured_by_a_surviving_pattern()[source]¶
The quiet failure: a lost exact rule whose URL now goes elsewhere.
Losing a redirect is visible to anyone who follows the URL. Having it answered by a broader pattern that outlived it is not, since the request still redirects, just never where its author wrote.