mozilla / addons

☂ Umbrella repository for Mozilla Addons ✨
Other
127 stars 41 forks source link

[Task]: Use FactoryBoy to generate model factories #15073

Open KevinMind opened 1 month ago

KevinMind commented 1 month ago

Description

I'm regularly frustrated with the cutsom factory methods we have. It's often difficult to understand what arguments to pass, what they do, and how factories relate to each other.

It's not terrible, but there are better options out there. https://factoryboy.readthedocs.io/en/stable/index.html

Let's use factory boy (or something better should it exist) to define our factories. This will make our tests easier to maintain, make it easier to generate test data for verifying PRs and seeding the DB and allow us to unify the way of generating data across the development environment (no more fixtures)

Acceptance Criteria

  ### Milestones/checkpoints
  - [ ] Install factory boy
  - [ ] Replace model by model factory instances with factory boy classes
  - [ ] Replace seeding with factories

Checks

┆Issue is synchronized with this Jira Task

diox commented 1 month ago

We have wanted to do this in the past (https://github.com/mozilla/addons/issues/5595, and also all the issues about landfill - which is aptly named, it is absolutely terrible) but never got the bandwidth for it, it's not a trivial task, there are lots of little details that are handled by those factories, and tons of tests depend on it.

KevinMind commented 1 month ago

I know. Just want a task that won't be burned in the fires of stalebot. I would be so excited if we could get this done.

KevinMind commented 1 month ago

Also, no reason we would have to do all at once.

diox commented 1 month ago

It would have been useful for blocked versions recently. We could start with a easy factory like user_factory, but for the rest if would be much more involved.