readthedocs.org
readthedocs.org copied to clipboard
Refactor JSON fixtures to a scripted logic
Details
Currently, we maintain fixtures here: https://github.com/readthedocs/readthedocs.org/blob/main/readthedocs/projects/fixtures/test_data.json
Since it's not clear that the intention/coupling of these fixtures are for either
- Test cases
- Demoing / manual tests
...we should probably refactor this to a separate script or test fixture decorator:
Suggestion by @humitos for a quick solution:
https://github.com/readthedocs/readthedocs.org/pull/9319#discussion_r895568755
Note from @stsewd that current fixtures are included in tests:
https://github.com/readthedocs/readthedocs.org/issues/8914#issuecomment-1154039496
Expected Result
Better developer experience maintaining fixtures, better or more fixtures, better test cases
Actual Result
No bugs related to this
Hi @benjaoming I would like to work on this. Continuing from #8914 . However I would need some guidance. Thanks!
@tanvimoharir
That sounds great!
Expanding on comment from @humitos, I would propose the following adjustments:
- Write a management command for the
projects
application and call itfixtures_projects
- Make it a tiny bit robust, i.e. use
get_or_create
or check that the project isn't already created when loading - Maintain fixtures as a dictionary directly in
fixtures_projects.py
, do not factor into a separate data file (JSON/YAML etc) unless the need actually arises. - Call
call_command
fromsetUp
where test case previously used fixtures. - Update docker-compose entrypoint web.sh, replacing
loaddata
with a call to the new management command
(I'll keep updating the above list as other team members may have inputs)