You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
boost_weblate/endpoint/services.py mixes pure helpers with Weblate ORM usage, filesystem scanning, and git/subprocess calls, so it was hard to cover under the global coverage gate without a large test suite. Coverage was configured to omit that file entirely, which hid regressions in core sync logic.
Acceptance Criteria
Unit tests exercise pure helpers (_submodule_slug, truncate_component_name, truncate_component_slug, _build_extension_to_format with patched FILE_FORMATS).
Unit tests exercise BoostComponentService behaviour using mocks for subprocess.run, Weblate models (Project, Component, Language), transaction, and filesystem/OS helpers where needed, including success and failure paths (timeouts, permission checks, missing configs, git errors).
scan_documentation_files is covered using real temporary directories for realistic layout cases.
High-level flows process_submodule and process_all are covered by patching inner service methods and asserting structured success/error results.
Coverage collection includes endpoint/services.py (the dedicated omit entry for that path is removed from pyproject.toml).
Implementation Notes
Prefer unittest.mock.patch / MagicMock at the import site used by services (e.g. boost_weblate.endpoint.services.subprocess.run) so behaviour under test matches production call paths.
Use a small factory (_make_svc) to construct BoostComponentService with defaults and override only fields relevant to each test class.
ORM-heavy paths avoid a live database by stubbing objects.get_or_create, filter, get, and component methods such as create_translations_immediate and add_new_language.
Problem
boost_weblate/endpoint/services.pymixes pure helpers with Weblate ORM usage, filesystem scanning, andgit/subprocesscalls, so it was hard to cover under the global coverage gate without a large test suite. Coverage was configured to omit that file entirely, which hid regressions in core sync logic.Acceptance Criteria
_submodule_slug,truncate_component_name,truncate_component_slug,_build_extension_to_formatwith patchedFILE_FORMATS).BoostComponentServicebehaviour using mocks forsubprocess.run, Weblate models (Project,Component,Language),transaction, and filesystem/OS helpers where needed, including success and failure paths (timeouts, permission checks, missing configs, git errors).scan_documentation_filesis covered using real temporary directories for realistic layout cases.process_submoduleandprocess_allare covered by patching inner service methods and asserting structured success/error results.endpoint/services.py(the dedicatedomitentry for that path is removed frompyproject.toml).Implementation Notes
unittest.mock.patch/MagicMockat the import site used byservices(e.g.boost_weblate.endpoint.services.subprocess.run) so behaviour under test matches production call paths._make_svc) to constructBoostComponentServicewith defaults and override only fields relevant to each test class.objects.get_or_create,filter,get, and component methods such ascreate_translations_immediateandadd_new_language.References
pyproject.tomltests/endpoint/test_services.py