Skip to content

Format Handler Tests (tests/formats/test_quickbook.py) #8

@whisper67265

Description

@whisper67265

Problem

The QuickBook format handler (item 2) must be validated against Weblate's format contract. Tests must verify round-trip fidelity, monolingual behavior, extension autodetection, and correct interaction with the Weblate translation unit API. Without these tests, format handler bugs could silently corrupt translations.

Acceptance Criteria

  • tests/formats/test_quickbook.py exists with pytest-style test functions
  • Round-trip test: load a .qbk fixture file via QuickBookFormat.load(), then save() — output matches input byte-for-byte
  • Monolingual contract test: verify QuickBookFormat.monolingual is True and that load() produces units with source populated and target empty
  • autodetect_extensions test: verify (".qbk",) is returned
  • format_id test: verify the format returns "quickbook"
  • name test: verify human-readable name is returned
  • Edge case: load a file with code blocks and verify they are not split into translatable units
  • Edge case: load a file with tables and verify cell content is extracted as separate units
  • Test fixtures are stored in tests/fixtures/ as .qbk files

Implementation Notes

  • Create at least 3 fixture files: a minimal single-section file, a complex file with tables/code/images, and an empty file.
  • If Weblate's test infrastructure provides a BaseFormatTest mixin, consider subclassing it for contract conformance.
  • These tests validate the format handler's Weblate integration; William's tests/utils/test_quickbook.py (item 9) validates the underlying parser independently.
  • Use pytest-tmp-files or tmp_path fixture for any write-back tests.

References

  • Related files: tests/formats/test_quickbook.py, tests/fixtures/*.qbk, src/boost_weblate/formats/quickbook.py
  • Upstream: weblate/formats/tests/test_txt.py for test patterns

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions