-
Notifications
You must be signed in to change notification settings - Fork 722
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
Add users and groups as part of generatedata.py #5968
base: main
Are you sure you want to change the base?
Conversation
Creates group with int number of users * staff: 15 * small_group: 10 * medium_group: 15 * large_group: 1000 * xlarge_group: 5000 All usernames will start with group name for easy testing Usernames are a concatenation of [group name]+User+count * Example: small_groupUser1, medium_groupUser10, etc.
@smithellis is this still relevant/valid? |
I think this was a casual Friday bit of work. I like it and find it useful, but if you don't, feel free to close. Stemmed from having the messaging work and needing to test with various group sizes. |
In that case, personally I would use the test factories for User and Groups. Please also move this under the |
I moved this to scripts - not sure what you were saying about the factories? They are in use. Did you mean to modify factories or add to factories or...? |
# Make the users for this group | ||
for _ in range(user_count): | ||
user_name = f"{group_name}User{_}" | ||
u = UserFactory(username=user_name, groups=[g]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be enough to create the user without the need to call the save()
method
def generate_sampledata(options): | ||
"""Generate user and group sample data.""" | ||
for group_name, user_count in GROUPS.items(): | ||
g = GroupFactory(name=group_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be enough to create the group without the need to call the save()
method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GroupFactory.create(args)
} | ||
|
||
|
||
def generate_sampledata(options): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the options
used anywhere?
print(f"Created group {group_name}") | ||
|
||
# Make the users for this group | ||
for _ in range(user_count): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use UserFactory.create_batch(size, ...
Creates group with int number of users
All usernames will start with group name for easy testing Usernames are a concatenation of [group name]+User+count