readthedocs.org icon indicating copy to clipboard operation
readthedocs.org copied to clipboard

Refactor JSON fixtures to a scripted logic

Open benjaoming opened this issue 2 years ago • 2 comments

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

  1. Test cases
  2. 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

benjaoming avatar Jun 14 '22 14:06 benjaoming

Hi @benjaoming I would like to work on this. Continuing from #8914 . However I would need some guidance. Thanks!

tanvimoharir avatar Jun 30 '22 13:06 tanvimoharir

@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 it fixtures_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 from setUp 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)

benjaoming avatar Jun 30 '22 13:06 benjaoming