Skip to content
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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

smithellis
Copy link
Contributor

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.

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.
@akatsoulas
Copy link
Collaborator

@smithellis is this still relevant/valid?

@smithellis
Copy link
Contributor Author

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.

@akatsoulas
Copy link
Collaborator

In that case, personally I would use the test factories for User and Groups. Please also move this under the scripts folder under the root level of the repo. Let me know when it's ready for a final pass

@smithellis
Copy link
Contributor Author

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])
Copy link
Collaborator

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)
Copy link
Collaborator

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

Copy link
Collaborator

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):
Copy link
Collaborator

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):
Copy link
Collaborator

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, ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants