Skip to content

Add a dummy data management command #268

@jaredlockhart

Description

@jaredlockhart

Let's make a management command to populate the db with dummy data for easy testing.

You can use the test factories to make this very simple, for instance

from experimenter.experiments.tests.factories import ExperimentFactory
ExperimentFactory.create_with_status(Experiment.STATUS_DRAFT)

will create a fully formed experiment with all the necessary related data. So I think for this management command, it should take two optional parameters

python manage.py create-dummy-experiments <number of experiments> <optional status>

Number of experiments: default to 10

Optional status: If status is specified, create all experiments with that status. If no status is specified, just choose at random for each experiment by doing something like

import random
random_status = random.choice(Experiment.STATUS_CHOICES)[0]
ExperimentFactory.create_with_status(random_status)

And then add tests and add an alias to the Makefile (look at the load-locales-countries to see an example). Let me know if you have any questions!

Metadata

Metadata

Assignees

Labels

Taskhttps://mozilla.github.io/task-defect-enhancement/index.html

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions