Problem
The boost endpoint's HTTP layer (views, URL routing, authentication) has no test coverage. Without tests, regressions in input validation, auth enforcement, or response shapes will go undetected. A comprehensive HTTP test suite is needed that exercises the DRF views through Django's test client, covering happy paths, validation failures, and authentication edge cases.
Acceptance Criteria
Implementation Notes
Use unittest.mock.patch to mock tasks.add_or_update.delay and assert it was called with the expected arguments. Use DRF's APIClient with credentials() for auth tests. Create a test user with User.objects.create_user() in setUp. The tests should be in tests/test_views.py or tests/endpoints/test_http.py, consistent with the existing test layout. Use @override_settings(CELERY_TASK_ALWAYS_EAGER=True) only if testing task execution end-to-end in a separate suite, not here.
References
- Related files:
tests/test_views.py (or tests/endpoints/test_http.py), src/boost_weblate/views.py, src/boost_weblate/urls.py
- Depends on:
views.py, urls.py, tasks.py
Problem
The boost endpoint's HTTP layer (views, URL routing, authentication) has no test coverage. Without tests, regressions in input validation, auth enforcement, or response shapes will go undetected. A comprehensive HTTP test suite is needed that exercises the DRF views through Django's test client, covering happy paths, validation failures, and authentication edge cases.
Acceptance Criteria
GET /info/returns200with JSON containingname,version, andcapabilitieskeysPOST /add-or-update/with missing required fields returns400with a structured error body listing the missing fieldsPOST /add-or-update/with invalid field types (e.g.,languagesas a string instead of a list) returns400POST /add-or-update/with valid payload and valid authentication returns202with a JSON body containingtask_idtask_idin the202response is a valid UUID stringPOST /add-or-update/returns401or403401or403POSTAPITestCaseor Django'sTestCasewithself.clientand do not require a running Celery workerImplementation Notes
Use
unittest.mock.patchto mocktasks.add_or_update.delayand assert it was called with the expected arguments. Use DRF'sAPIClientwithcredentials()for auth tests. Create a test user withUser.objects.create_user()insetUp. The tests should be intests/test_views.pyortests/endpoints/test_http.py, consistent with the existing test layout. Use@override_settings(CELERY_TASK_ALWAYS_EAGER=True)only if testing task execution end-to-end in a separate suite, not here.References
tests/test_views.py(ortests/endpoints/test_http.py),src/boost_weblate/views.py,src/boost_weblate/urls.pyviews.py,urls.py,tasks.py