← Về thư mục
tests/citation-management/test_scripts.py
- BibTeXTestCase · class · L61-L71 — class BibTeXTestCase(unittest.TestCase)
- setUp · method · L62-L66 — def setUp(self) -> None
- bib · method · L68-L71 — def bib(self, text: str = BIBLIOGRAPHY) -> str
- ParsingTests · class · L74-L148 — class ParsingTests(BibTeXTestCase)
- test_entries_are_parsed_with_type_key_and_fields · method · L75-L81 — def test_entries_are_parsed_with_type_key_and_fields(self) -> None
- test_an_empty_file_parses_to_no_entries · method · L83-L84 — def test_an_empty_file_parses_to_no_entries(self) -> None
- test_comments_outside_entries_are_ignored · method · L86-L95 — def test_comments_outside_entries_are_ignored(self) -> None
- test_an_entry_closed_on_the_same_line_is_recognised · method · L97-L104 — def test_an_entry_closed_on_the_same_line_is_recognised(self) -> None: # Single-line entries are legal BibTeX. The brace-depth parser reads # them; the regex it replaced anchored on
\n} and skipped them.
- test_a_nested_brace_in_a_title_survives_parsing · method · L106-L120 — def test_a_nested_brace_in_a_title_survives_parsing(self) -> None: # Capitalisation protection puts braces inside a field value. A #
\{([^}]*)\} field pattern truncates at the inner brace and silently # corrupts the bibliography, which is what this guards.
- test_a_comma_inside_a_field_does_not_split_the_field · method · L122-L127 — def test_a_comma_inside_a_field_does_not_split_the_field(self) -> None
- test_string_and_comment_blocks_are_not_treated_as_entries · method · L129-L137 — def test_string_and_comment_blocks_are_not_treated_as_entries(self) -> None
- test_quoted_field_values_are_read_as_well_as_braced_ones · method · L139-L143 — def test_quoted_field_values_are_read_as_well_as_braced_ones(self) -> None
- test_an_unreadable_file_returns_no_entries_rather_than_raising · method · L145-L148 — def test_an_unreadable_file_returns_no_entries_rather_than_raising(self) -> None
- FixTests · class · L151-L202 — class FixTests(BibTeXTestCase)
- _fixed_fields · method · L152-L154 — def _fixed_fields(self, **fields) -> dict
- test_a_single_hyphen_page_range_becomes_an_en_dash_range · method · L156-L158 — def test_a_single_hyphen_page_range_becomes_an_en_dash_range(self) -> None: # BibTeX renders
583-589 as a hyphen, not an en dash.
- test_an_already_correct_range_is_left_alone · method · L160-L161 — def test_an_already_correct_range_is_left_alone(self) -> None
- test_a_pp_prefix_is_stripped · method · L163-L166 — def test_a_pp_prefix_is_stripped(self) -> None
- test_a_doi_loses_its_url_prefix · method · L168-L176 — def test_a_doi_loses_its_url_prefix(self) -> None: # A DOI stored as a URL fails every downstream Crossref lookup.
- test_a_bare_doi_is_untouched · method · L178-L179 — def test_a_bare_doi_is_untouched(self) -> None
- test_author_separators_are_normalised_to_and · method · L181-L189 — def test_author_separators_are_normalised_to_and(self) -> None
- test_a_doubled_and_is_collapsed · method · L191-L194 — def test_a_doubled_and_is_collapsed(self) -> None
- test_fixing_does_not_mutate_the_original_entry · method · L196-L199 — def test_fixing_does_not_mutate_the_original_entry(self) -> None
- test_absent_fields_are_not_invented · method · L201-L202 — def test_absent_fields_are_not_invented(self) -> None
- DeduplicationTests · class · L205-L237 — class DeduplicationTests(BibTeXTestCase)
- _entries · method · L206-L209 — def _entries(self, *specs) -> list
- test_entries_sharing_a_doi_collapse_to_one · method · L211-L215 — def test_entries_sharing_a_doi_collapse_to_one(self) -> None
- test_entries_sharing_a_citation_key_collapse_to_one · method · L217-L219 — def test_entries_sharing_a_citation_key_collapse_to_one(self) -> None
- test_distinct_entries_all_survive · method · L221-L225 — def test_distinct_entries_all_survive(self) -> None
- test_the_first_occurrence_is_kept · method · L227-L233 — def test_the_first_occurrence_is_kept(self) -> None
- test_entries_without_a_doi_are_deduplicated_by_key_alone · method · L235-L237 — def test_entries_without_a_doi_are_deduplicated_by_key_alone(self) -> None
- SortTests · class · L240-L282 — class SortTests(BibTeXTestCase)
- setUp · method · L241-L246 — def setUp(self) -> None
- test_the_default_sort_is_by_citation_key · method · L248-L252 — def test_the_default_sort_is_by_citation_key(self) -> None
- test_sorting_by_year_author_and_title · method · L254-L265 — def test_sorting_by_year_author_and_title(self) -> None
- test_descending_reverses_the_order · method · L267-L271 — def test_descending_reverses_the_order(self) -> None
- test_entries_missing_the_sort_field_go_last · method · L273-L276 — def test_entries_missing_the_sort_field_go_last(self) -> None
- test_an_unknown_sort_field_falls_back_to_the_key · method · L278-L282 — def test_an_unknown_sort_field_falls_back_to_the_key(self) -> None
- RenderTests · class · L285-L336 — class RenderTests(BibTeXTestCase)
- test_a_formatted_entry_reparses_to_the_same_fields · method · L286-L296 — def test_a_formatted_entry_reparses_to_the_same_fields(self) -> None
- test_fields_are_emitted_in_the_documented_order · method · L298-L306 — def test_fields_are_emitted_in_the_documented_order(self) -> None
- test_braces_are_balanced · method · L308-L312 — def test_braces_are_balanced(self) -> None
- test_a_protected_title_round_trips_without_losing_a_brace · method · L314-L329 — def test_a_protected_title_round_trips_without_losing_a_brace(self) -> None: # The regression that motivated the parser rewrite: this pipeline # previously emitted
{... with {AlphaFold} -- one brace short, so the # file no longer compiled and every later entry was swallowed.
- test_formatting_is_idempotent · method · L331-L336 — def test_formatting_is_idempotent(self) -> None
- EndToEndTests · class · L339-L354 — class EndToEndTests(BibTeXTestCase)
- test_formatting_a_file_applies_every_fix · method · L340-L349 — def test_formatting_a_file_applies_every_fix(self) -> None
- test_the_result_still_parses · method · L351-L354 — def test_the_result_still_parses(self) -> None
- ValidationTests · class · L357-L438 — class ValidationTests(BibTeXTestCase)
- setUp · method · L358-L360 — def setUp(self) -> None
- test_a_complete_article_raises_no_errors · method · L362-L374 — def test_a_complete_article_raises_no_errors(self) -> None
- test_a_missing_required_field_is_reported · method · L376-L384 — def test_a_missing_required_field_is_reported(self) -> None
- test_duplicate_detection_finds_repeated_entries · method · L386-L388 — def test_duplicate_detection_finds_repeated_entries(self) -> None
- test_distinct_entries_are_not_reported_as_duplicates · method · L390-L392 — def test_distinct_entries_are_not_reported_as_duplicates(self) -> None
- test_manuscript_citation_keys_are_extracted · method · L394-L403 — def test_manuscript_citation_keys_are_extracted(self) -> None
- test_a_manuscript_with_no_citations_yields_none · method · L405-L408 — def test_a_manuscript_with_no_citations_yields_none(self) -> None
- test_the_valid_entry_count_never_goes_negative · method · L410-L418 — def test_the_valid_entry_count_never_goes_negative(self) -> None: # Several errors can land on one entry. Subtracting the error count # from the entry count reported
Valid entries: -2 for a one-entry # file, so the figure counts distinct failing entries instead.
- test_a_venue_shortfall_is_a_warning_not_an_error · method · L420-L429 — def test_a_venue_shortfall_is_a_warning_not_an_error(self) -> None: # Reference-list length is editorial judgement, so falling under a # venue rule of thumb must not fail the run.
- test_an_explicit_min_count_is_enforced_as_an_error · method · L431-L435 — def test_an_explicit_min_count_is_enforced_as_an_error(self) -> None
- test_venue_standards_are_available_without_running_a_validation · method · L437-L438 — def test_venue_standards_are_available_without_running_a_validation(self) -> None
- PageTests · class · L441-L467 — class PageTests(unittest.TestCase)
- test_a_single_hyphen_range_becomes_an_en_dash_range · method · L442-L443 — def test_a_single_hyphen_range_becomes_an_en_dash_range(self) -> None
- test_an_already_correct_range_is_not_doubled · method · L445-L447 — def test_an_already_correct_range_is_not_doubled(self) -> None: # A blanket
replace('-', '--') turned this into 583----589.
- test_an_abbreviated_end_page_is_expanded · method · L449-L453 — def test_an_abbreviated_end_page_is_expanded(self) -> None: # PubMed's MedlinePgn abbreviates the end page;
1123--30 is not a # page range any reader or reference manager can resolve.
- test_an_article_number_is_left_alone · method · L455-L458 — def test_an_article_number_is_left_alone(self) -> None
- test_a_pp_prefix_is_stripped · method · L460-L461 — def test_a_pp_prefix_is_stripped(self) -> None
- test_an_en_dash_is_normalised · method · L463-L464 — def test_an_en_dash_is_normalised(self) -> None
- test_an_empty_value_yields_an_empty_string · method · L466-L467 — def test_an_empty_value_yields_an_empty_string(self) -> None
- CitationKeyTests · class · L470-L503 — class CitationKeyTests(unittest.TestCase)
- test_a_comma_separated_name_uses_the_surname · method · L471-L475 — def test_a_comma_separated_name_uses_the_surname(self) -> None
- test_a_pubmed_style_name_uses_the_leading_surname · method · L477-L479 — def test_a_pubmed_style_name_uses_the_leading_surname(self) -> None: #
Smith JA is surname-first; taking the last token yields JA.
- test_a_western_style_name_uses_the_trailing_surname · method · L481-L482 — def test_a_western_style_name_uses_the_trailing_surname(self) -> None
- test_accents_and_punctuation_are_removed · method · L484-L488 — def test_accents_and_punctuation_are_removed(self) -> None: # A key reaches LaTeX and sometimes a file path, and its source is a # publisher-controlled record.
- test_a_key_is_always_safe_to_use · method · L490-L494 — def test_a_key_is_always_safe_to_use(self) -> None
- test_a_missing_year_becomes_a_placeholder · method · L496-L497 — def test_a_missing_year_becomes_a_placeholder(self) -> None
- test_the_same_paper_from_two_sources_gets_the_same_key · method · L499-L503 — def test_the_same_paper_from_two_sources_gets_the_same_key(self) -> None: # This is what makes cross-source deduplication possible at all.
- TitleProtectionTests · class · L506-L519 — class TitleProtectionTests(unittest.TestCase)
- test_an_acronym_is_braced · method · L507-L511 — def test_an_acronym_is_braced(self) -> None
- test_protection_is_idempotent · method · L513-L515 — def test_protection_is_idempotent(self) -> None
- test_an_acronym_inside_a_longer_word_is_untouched · method · L517-L519 — def test_an_acronym_inside_a_longer_word_is_untouched(self) -> None
- RekeyTests · class · L522-L535 — class RekeyTests(BibTeXTestCase)
- test_entries_are_rekeyed_to_the_shared_scheme · method · L523-L526 — def test_entries_are_rekeyed_to_the_shared_scheme(self) -> None
- test_a_key_collision_gets_a_suffix · method · L528-L535 — def test_a_key_collision_gets_a_suffix(self) -> None
- EntryRenderingTests · class · L539-L601 — class EntryRenderingTests(unittest.TestCase)
- setUp · method · L542-L543 — def setUp(self) -> None
- _fields · method · L545-L546 — def _fields(self, bibtex: str) -> dict
- test_a_book_keeps_its_publisher · method · L548-L555 — def test_a_book_keeps_its_publisher(self) -> None: #
publisher was extracted from Crossref and then dropped by the # writer, so every @book failed its own required-field check.
- test_a_report_maps_its_publisher_to_institution · method · L557-L562 — def test_a_report_maps_its_publisher_to_institution(self) -> None
- test_a_chapter_uses_booktitle_rather_than_journal · method · L564-L570 — def test_a_chapter_uses_booktitle_rather_than_journal(self) -> None
- test_an_unpublished_preprint_is_misc_not_a_journalless_article · method · L572-L581 — def test_an_unpublished_preprint_is_misc_not_a_journalless_article(self) -> None: # arXiv mints DOIs for unpublished preprints, so a DOI alone must not # promote an entry to @article -- that yields an article with no # journal, which fails validation every time.
- test_a_published_preprint_gains_its_journal · method · L583-L585 — def test_a_published_preprint_gains_its_journal(self) -> None
- test_only_one_note_field_is_emitted · method · L587-L593 — def test_only_one_note_field_is_emitted(self) -> None: # Two
note lines in one entry is a BibTeX error.
- test_a_pubmed_entry_key_is_shared_scheme_and_pages_expand · method · L595-L601 — def test_a_pubmed_entry_key_is_shared_scheme_and_pages_expand(self) -> None
- OpenAlexTests · class · L605-L644 — class OpenAlexTests(unittest.TestCase)
- setUp · method · L606-L607 — def setUp(self) -> None
- test_an_abstract_is_rebuilt_from_its_inverted_index · method · L609-L613 — def test_an_abstract_is_rebuilt_from_its_inverted_index(self) -> None
- test_an_absent_abstract_yields_an_empty_string · method · L615-L616 — def test_an_absent_abstract_yields_an_empty_string(self) -> None
- test_a_work_is_flattened_to_the_shared_metadata_shape · method · L618-L633 — def test_a_work_is_flattened_to_the_shared_metadata_shape(self) -> None
- test_a_single_page_work_does_not_become_a_range · method · L635-L637 — def test_a_single_page_work_does_not_become_a_range(self) -> None
- test_a_preprint_renders_as_misc · method · L639-L644 — def test_a_preprint_renders_as_misc(self) -> None