Replace factory-boy/fake-factory test deps with plain fixtures
Overview
fake-factory==0.5.7 (test group) is the abandoned former name of faker; its final release 9999.9.9 is a tombstone that raises on import. Dependabot keeps proposing that bump (#14918), which would break the test suite. It survives only as a transitive dep of factory-boy==2.7.0 (2016). Remove both.
Complexity: Low Target branch: develop
Context
- factory-boy is used in 5 test files (
kolibri/core/{auth,logger,public}/test/); the surface to replace isDjangoModelFactory,SubFactory,LazyFunction,Sequence, andPostGenerationMethodCall.
The Change
- Remove
factory-boyandfake-factoryfrom thetestdependency group. - Replace the 17
factory.DjangoModelFactorysubclasses inkolibri/core/{auth,logger,public}/test/with plain builder helpers that create instances directly (Model.objects.create(...)). - Move fixture creation from per-test
setUpto class-levelsetUpTestData(created once per class, rolled back per test — faster). - Preserve the
SubFactoryrelationships (e.g. log → user) as helper behaviour. - Preserve
Sequence-based unique naming as helper behaviour.
Out of Scope
- Changing test assertions or coverage — the rewrite is behaviour-preserving.
- Other test-data libraries (e.g.
mixer).
Acceptance Criteria
- [ ]
factory-boyandfake-factoryremoved frompyproject.tomltest group and no longer present inuv.lock. - [ ] No
import factoryremains in the codebase. - [ ] The 5 affected test modules build fixtures via plain helpers in
setUpTestData. - [ ] Affected test suites pass (
kolibri/core/{auth,logger,public}/test/). - [ ] Dependabot PR #14918 closed as obsolete.
References
- Blocked bump: #14918
fake-factory→fakerrename: https://faker.readthedocs.io/en/master/#migration-from-fake-factory- Django
setUpTestData: https://docs.djangoproject.com/en/3.2/topics/testing/tools/#django.test.TestCase.setUpTestData
AI usage
Drafted with Claude Code, which investigated the dependency and its test-suite usage. Direction (drop rather than upgrade; setUpTestData) and final wording are mine.
Plan: Remove the abandoned fake-factory (transitive dep of factory-boy) from the test dependency group by replacing the 17 factory.DjangoModelFactory subclasses in kolibri/core/{auth,logger,public}/test/ with a small in-repo helper, with zero behavior change.
- [ ] Shared
ModelFactorybase helper - [ ] Rewrite
kolibri/core/auth/test/test_api.pyfactories - [ ] Rewrite
kolibri/core/logger/test/factory_logger.pyfactories - [ ] Rewrite
kolibri/core/auth/test/test_utils.pyfactories - [ ] Rewrite
kolibri/core/public/test/test_api.pyfactories - [ ] Swap
factory.django.mute_signalsintest_picture_passwords.py - [ ] Remove the dependency
- [ ] Full verification sweep
@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly
How was this generated?
- Implemented code following the pre-approved plan using test-driven development (red-green-refactor)
- Ran the project's full test suite and linter before committing
- For UI changes: captured live screenshots to verify rendering
- For backend changes: verified with example API/CLI output
The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.
The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.