GithubHelp home page GithubHelp logo

edwardr / fake-json-generator-py Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 17 KB

Simple Python CLI tool to create JSON files with dummy data to use for testing.

License: MIT License

Python 100.00%
faker json-data python-cli-tool testing-data python-cli

fake-json-generator-py's Introduction

Overview

Simple Python CLI tool to create JSON files with dummy data to use for testing. Uses dataclasses to define schemas so it can be easily customized to create new data exports or modify existing ones.

Uses Faker to generate most of the data as defined in the schema.

Requirements

Python 3.7+

Install Dependencies

pip install faker dataclasses-json

Usage

python generator.py --type [TYPE] --count [COUNT] [--output FILENAME]

The example:

python generator.py --type User --count 500

Will generate a JSON file with 500 users with the default filename of "fakeUser-[timestamp].json"

Schemas

Check the modules/schema.py file to see the default schemas of User, Blog, and Product. You can add any new schemas to this file and use the class name as the "Type" when running the generator. You can also modify the existing schemas as needed if you want to tweak the data.

@dataclass_json
@dataclass
class User:
  id:             int = field(default_factory=lambda: random.randint(1,9999))
  username:       str = field(default_factory=lambda: fake.user_name())
  first_name:     str = field(default_factory=lambda: fake.first_name())
  last_name:      str = field(default_factory=lambda: fake.last_name())
  email:          str = field(default_factory=lambda: fake.ascii_safe_email())
  street_address: str = field(default_factory=lambda: fake.street_address())
  city:           str = field(default_factory=lambda: fake.city())
  state:          str = field(default_factory=lambda: fake.state())
  postal_code:    str = field(default_factory=lambda: fake.postcode())
  country:        str = field(default_factory=lambda: fake.country())

The property default factories mostly use Faker library functions. See the Faker documentation for additional values you can generate.

fake-json-generator-py's People

Contributors

edwardr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.