Last active
May 23, 2020 14:38
-
-
Save kamilglod/501ace50387a7b433faf4cb8c7222de2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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