A package to generate mock data
Project description
pymocko
This is to generate mock data
Installation:
python -m pip install pymocko
Development Eviroment:
git clone https://github.com/datnguye/pymocko.git
cd pymocko/pymocko
python -m venv env
.\env\Scripts\activate
OR source env/bin/activate (linux)
python -m pip install -r requirements.txt
Run test cases:
cd ..
python run.py
Version used
Python 3.7.5
USAGE
Mokcing by json model:
print("Mock model")
print(model.mock(schema_json={"id":"num", "name":"word", "qty":"num", "unit_price":"price", "created_at":"date", "updated_at":"date"}, count=5))
print(model.mock(schema_json={"id":"num", "user_name":"word", "name":"word", "dob":"date", "phone_no":"char", "email":"word", "gender":"word", "ip_address":"char"}, count=5))
print(model.mock(schema_json={"id":"num", "name":"word", "qty": { "stocked": "num", "online": "num" }, "price":[ { "unit_price":"price", "effective_date": "date"} ], "created_at":"date", "updated_at":"date"}, count=3))
print(model.mock(schema_json={"id":"num", "name":"word", "tags": ["word"], "reference_names": [ "word" ], "qty": { "stocked": "num", "online": "num" }, "price":[ { "unit_price":"price", "effective_date": "date"} ], "created_at":"date", "updated_at":"date"}, count=3))
Randomize number:
from pymocko import num
print(num.mock())
print(num.mock(f=1, t=10))
print(num.mock(f=1, t=1000, neg=True))
Randomize price:
from pymocko import price
print(price.mock())
print(price.mock(f=1000, t=10000))
print(price.mock(f=0, t=2500, decimal=0))
print(price.mock(f=0, t=2500, decimal=4))
print(price.mock(f=0, t=2500, neg=True))
Randomize date:
from pymocko import date
print(date.mock())
print(date.mock(f=datetime.datetime(2020,6,1)))
Randomize character:
from pymocko import char
print(char.mock())
print(char.mock(no_of_char=20,number_inc=True))
print(char.mock(no_of_char=30,number_inc=True,special_inc=True))
Randomize word/sentence:
from pymocko import word
print(word.mock())
print(word.mock(no_of_word=20))
print(word.mock(no_of_word=10, upper_first=True))
print(word.mock_phone())
print(word.mock_phone(prefix="+84"))
print(word.mock_email())
print(word.mock_email(domain="data.com"))
print(word.mock_gender())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pymocko-0.1.4.tar.gz
(11.0 kB
view details)
Built Distribution
pymocko-0.1.4-py3-none-any.whl
(12.2 kB
view details)
File details
Details for the file pymocko-0.1.4.tar.gz
.
File metadata
- Download URL: pymocko-0.1.4.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bcc2385320b908d46e979ef33175112c92b8fb3bce321bbc7c3da812cf6aebd9 |
|
MD5 | e839240c02e189d4252ce06ab5ea46b8 |
|
BLAKE2b-256 | af325596337dc59856653a1bb105d64a07c9392f49475a90b0adcd2f94e6e678 |
File details
Details for the file pymocko-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: pymocko-0.1.4-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b226806279441a0877ba6e48e4298cb3d88de7db7a676ef5b828f08e86bd11b9 |
|
MD5 | 687aa3a4d44d5343d201ca99cb4d533e |
|
BLAKE2b-256 | 65c457466e4185e69275f97f78d7bda38e60310f3448e260e5f8cfe6b89b0e9e |