Skip to content

CMS-948: data creation scripts#445

Open
RealOrangeOne wants to merge 45 commits intomainfrom
CMS-948-data-creation-scripts
Open

CMS-948: data creation scripts#445
RealOrangeOne wants to merge 45 commits intomainfrom
CMS-948-data-creation-scripts

Conversation

@RealOrangeOne
Copy link
Copy Markdown
Contributor

What is the context of this PR?

We need a way to create test data in bulk for performance testing etc.

https://officefornationalstatistics.atlassian.net/browse/CMS-948

Data creation is seeded, meaning it can be recreated reliably.

Data is identified by a prefix. To save complexity, it's only possible to delete all test data, rather than specific seeds.

How to review

There are 2 new management commands.

  • create_test_data creates data based on a seed.
  • delete_test_data removes all test data from the system (based on the prefix)

Follow-up Actions

List any follow-up actions (if applicable), like needed documentation updates or additional testing.

@MaciekBaron MaciekBaron added the component: Tooling Makefiles, linters, container instrumentation etc label Jan 2, 2026
This keeps the command parts separate
By default, they enqueue tasks when instances are saved, which is unnecessary when many of the instances are about to be
deleted.
This factory is definitely configured incorrectly, but something about the model, dependent tests or factory itself
requires that it work this way.
They may not have been indexed yet
@RealOrangeOne RealOrangeOne marked this pull request as ready for review January 21, 2026 14:52
@RealOrangeOne RealOrangeOne requested a review from a team as a code owner January 21, 2026 14:52

class PageCreationConfig(ModelCreationConfig):
published: FractionalFloat = 0.5
revisions: NonNegativeInt | RangeConfig = 0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I misunderstood, aren't all Pages guaranteed to have at least one revision in a normal environment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the revision is the history, so the first draft save of a page won't necessarily have a revision. That's my understanding at least, I may very well be wrong.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a test and it seems that every page has at least one revision:

  • I created a draft page by entering basic information in a new page view and clicking "Save Draft"
  • Grabbed the ID from the URL (28)
  • Ran the following: len(InformationPage.objects.get(pk=28).revisions.all())
  • Returns 1

So I think we get the first revision for free and the range should start at 1 (and we should add n-1 additional revisions)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL. Thanks for looking into this. Yeah I agree this should be tweaked.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that's only true when creating pages through the CMS - here there's no revision automatically created, so 0 is still valid.

@MebinAbraham MebinAbraham added the On Hold ✋ Pull request is currently deprioritised and on hold, but not blocked label Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: Tooling Makefiles, linters, container instrumentation etc On Hold ✋ Pull request is currently deprioritised and on hold, but not blocked

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants