Skip to content

Refactor JSON fixtures to a scripted logic #9332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
benjaoming opened this issue Jun 14, 2022 · 2 comments
Open

Refactor JSON fixtures to a scripted logic #9332

benjaoming opened this issue Jun 14, 2022 · 2 comments
Labels
Improvement Minor improvement to code Priority: low Low priority Sprintable Small enough to sprint on

Comments

@benjaoming
Copy link
Contributor

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:

#9319 (comment)

Note from @stsewd that current fixtures are included in tests:

#8914 (comment)

Expected Result

Better developer experience maintaining fixtures, better or more fixtures, better test cases

Actual Result

No bugs related to this

@benjaoming benjaoming added Improvement Minor improvement to code Sprintable Small enough to sprint on Priority: low Low priority labels Jun 14, 2022
@tanvimoharir
Copy link
Contributor

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

@benjaoming
Copy link
Contributor Author

@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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Minor improvement to code Priority: low Low priority Sprintable Small enough to sprint on
Projects
None yet
Development

No branches or pull requests

2 participants