Skip to content

Instantly share code, notes, and snippets.

@kamilglod
Last active May 23, 2020 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamilglod/501ace50387a7b433faf4cb8c7222de2 to your computer and use it in GitHub Desktop.
Save kamilglod/501ace50387a7b433faf4cb8c7222de2 to your computer and use it in GitHub Desktop.
import json
from sys import argv
from faker import Faker
from .users import User
from .config import USERS_DATASET_PATH
def generate_users(size: int) -> None:
fake = Faker()
rows = []
for id_ in range(size):
rows.append(
{
'id': id_ + 1,
'enabled': fake.pybool(),
'status': fake.random_element([s.value for s in User.Status]),
'custom_properties': fake.pydict(value_types=('str', 'float', 'int',)),
'first_name': fake.first_name(),
'last_name': fake.last_name(),
'address': fake.address(),
'company': fake.company(),
'credit_card': fake.credit_card_full(),
'currency': fake.currency_code(),
'created_at': fake.date_time().isoformat(),
'bio': fake.text(),
'budget': fake.pyfloat(min_value=1),
'labels': [fake.color_name() for _ in range(10)],
},
)
USERS_DATASET_PATH.write_text(json.dumps(rows))
if __name__ == "__main__":
size = int(argv[1]) if len(argv) > 1 else 10
generate_users(size)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment