tests.test_broken_links moduleΒΆ
Tests for the broken links report: linkcheck parsing and the issue verdict.
- tests.test_broken_links.test_get_label(repo, expected)[source]ΒΆ
Only a repo whose name starts with
awesome-gets the fix-link label.
- tests.test_broken_links.test_parse_output_json_empty_file(tmp_path)[source]ΒΆ
Empty file returns no results.
- tests.test_broken_links.test_parse_output_json_skips_blank_lines(tmp_path)[source]ΒΆ
Blank lines in the file are skipped.
- tests.test_broken_links.test_parse_output_json_single_entry(tmp_path)[source]ΒΆ
Single entry is parsed correctly.
- tests.test_broken_links.test_parse_output_json_multiple_entries(tmp_path)[source]ΒΆ
Multiple entries are parsed correctly.
- tests.test_broken_links.test_parse_output_json_missing_info_field(tmp_path)[source]ΒΆ
Missing info field defaults to empty string.
- tests.test_broken_links.test_filter_by_status(status, expected_count)[source]ΒΆ
Only broken and timeout statuses are kept.
- tests.test_broken_links.test_filter_broken_mixed_statuses()[source]ΒΆ
Only broken and timeout are kept from a mixed list.
- tests.test_broken_links.test_report_single_broken_link()[source]ΒΆ
Single broken link generates a valid report.
- tests.test_broken_links.test_report_groups_by_file_alphabetically()[source]ΒΆ
Results are grouped by filename in alphabetical order.
- tests.test_broken_links.test_report_escapes_pipe_chars_in_info()[source]ΒΆ
Pipe characters in info are escaped to avoid breaking tables.
- tests.test_broken_links.test_report_source_url_links_filenames_and_lines()[source]ΒΆ
When source_url is provided, filenames and line numbers are linked.
- tests.test_broken_links.test_report_no_source_url_plain_text()[source]ΒΆ
Without source_url, filenames and line numbers are plain text.
- tests.test_broken_links.test_report_leaves_external_content_unsanitized(info)[source]ΒΆ
The report renderer passes tool output through; the caller sanitizes it.
Splitting the two is what lets the same report be written to a file, where the mention would be inert, or posted to an issue, where it would not.
test_lychee_output_sanitizedcovers the callerβs half.
- tests.test_broken_links.test_lychee_output_sanitized(tmp_path)[source]ΒΆ
Lychee markdown output is sanitized before embedding in issue body.
- tests.test_broken_links.test_lychee_section_reads_the_exit_code(exit_code, has_report, verdict, needle)[source]ΒΆ
Only exit 2 with a report reports broken links; 1 and 3 report nothing.
- tests.test_broken_links.test_sphinx_section_reads_the_statuses(tmp_path, status, verdict)[source]ΒΆ
Any broken or timed-out link makes the Sphinx verdict broken.
- tests.test_broken_links.test_a_failed_lychee_run_leaves_the_issue_alone(tmp_path, monkeypatch, exit_code)[source]ΒΆ
A run that did not complete never closes an open broken links issue.
It says nothing about the links, so claiming βNo more issues.β would close a report of links that may still be broken.
- tests.test_broken_links.test_a_failed_lychee_run_beside_broken_sphinx_links_files_both(tmp_path, monkeypatch)[source]ΒΆ
Broken links found anywhere are filed, with the incomplete run said so.
- tests.test_broken_links.test_a_completed_run_files_or_closes_the_issue(tmp_path, monkeypatch, exit_code, has_issues)[source]ΒΆ
A completed run decides the issue, either way.
- tests.test_broken_links.test_a_ci_run_detects_every_default(tmp_path, monkeypatch)[source]ΒΆ
In CI, the name, the linkcheck output and its source URL are all detected.
- tests.test_broken_links.test_no_repository_name_to_detect_is_an_error(tmp_path, monkeypatch)[source]ΒΆ
With neither
$GITHUB_REPOSITORYnor a clone, no name selects the label.
- tests.test_broken_links.test_no_checker_leaves_the_issue_alone(tmp_path, monkeypatch, caplog)[source]ΒΆ
With no checker run, nothing is known about the links: the issue stays.
No crawl and no Sphinx linkcheck output said a word about the links, so closing an open issue would announce fixes that nobody checked.
- tests.test_broken_links.test_cli_with_no_checker_exits_clean(tmp_path, monkeypatch)[source]ΒΆ
--no-lycheewith no linkcheck output leaves the issue, and exits 0.The job is advisory: a run that checked nothing must not turn it red.
- tests.test_broken_links.test_cli_without_a_repository_name_is_a_usage_error(tmp_path, monkeypatch)[source]ΒΆ
No
--repo-nameand nothing to detect one from fails before any check.
- tests.test_broken_links.test_run_lychee_skips_a_repository_with_no_documentation(tmp_path, monkeypatch)[source]ΒΆ
With no documentation file, lychee has nothing to check and never runs.
- tests.test_broken_links.test_run_lychee_reads_back_the_report_it_asked_for(tmp_path, monkeypatch)[source]ΒΆ
The crawl is the bare
run lycheeinvocation, plus the report flags.The report reaches the issue through the run itself, with no path agreed on with a workflow step.
- tests.test_broken_links.test_run_lychee_without_a_report_says_so(tmp_path, monkeypatch)[source]ΒΆ
A crawl that wrote no report carries none, whatever its exit code.