Skip to main content

Bulk Test Data Generator

Project description

Introduction

D-Thok is a python package to generate mock Test data in csv, json and xml format which can be used for any Mock Service, Performance Testing etc. It required input parameter as schema file where required structure is defined with data type, number of records, required format and file name.

Index

Setup Installation | Execution
Input Data Type alphabets | alpha-numeric | numeric | code | title | firstName | lastName | date_of_birth | choices | PhoneNumber | email | streetName | postcode | country | city | date | company | boolean | accountNumber | constant
Output File Format csv | json | xml

Input Datatype

Required input schema definition have to provided with all required Field name and required datatype in JSON format. Here is Sample input Schema definition file,

[
	{
	  "EmployeeID" 		: "code||PALO-%%-##LTD!@",
	  "Salutation"	   	: "alphabet||title",
	  "Firstname"  		: "alphabet|20|firstName",
	  "Lastname"   		: "alphabet|20|lastName",
	  "DOB"		   	: "date_of_birth|MinAge=30,MaxAge=40|%m-%d-%Y",
	  "Gender"	   	: "choices|('Male', 'Female')|",
	  "Mobile"     		: "PhoneNumber||India",
	  "emailId"	   	: "alphanum||email",
	  "Address"    		:
	  {

            "AddressType"   : "choices|('RES', 'OFF', 'WRK')|",
	    "Street-1"      : "alphabet|20|streetName",
	    "Street-2"      : "alphanum|20|streetName",
	    "Postalcode"    : "numeric|6|postcode",
	    "country"	    : "alphabet||country",
	    "city"	    : "alphabet||city"
	  },
	  "DOJ"		  	: "date|StartDate=20100223,EndDate=20200330|%Y-%m-%d",
	  "Client"	  	: "alphabet||company",
	  "Active"		: "boolean||",
	  "AccountNum"		: "alphanum|NONE|accountNumber",
	  "Salary"	    	: "constant|Monthly|",
          "DeskNumber"	    	: "constant|null|"
	}
]

Below are the sample data type syntax that can be used in input file.

alphabets

To generate random alphabetic String

Syntax:

"<Node Name>" : "alphabet|<length>"

e.g.

"ProductName" : "alphabet|30"

alphanum

To generate random alphanumeric String

Syntax:

"<Node Name>" : "alphanum|<length>"

e.g.

"ProductNumber" : "alphanum|30"

numeric

To generate random numeric value

Syntax:

"<Node Name>" : "numeric|<length>"

e.g.

"ProductID" : "numeric|30"

code

If you want to generate a code with some Prefix String

Syntax:

"<Node Name>" : "code||<Prefix String><regex>"
  • Number signs (‘#’) are replaced with a random digit (0 to 9)
  • Number signs (‘#’) are replaced with a random digit (0 to 9)
  • Percent signs (‘%’) are replaced with a random non-zero digit (1 to 9)
  • Exclamation marks (‘!’) are replaced with a random digit or an empty string
  • At symbols (‘@’) are replaced with a random non-zero digit or an empty string

e.g.

"EmployeeID" : "code||PALO-%%-##LTD!@"

Output: 
"EmployeeID": "PALO-26-12LTD8"

title

To generate random salutations like Dr. or Mr. or Mrs. or Mx.

Syntax:

"<Node Name>" : "alphabet||title"

e.g.

"Salutation" : "alphabet||title"

Output: 
"Salutation": "Mr."

firstName

Use to generate random firstName

Syntax:

"<Node Name>" : "alphabet|<Max length>|firstName"

e.g.

"Firstname" : "alphabet|20|firstName",

Output: 
"Firstname": "Samantha"

lastName

Use to generate random lastname

Syntax:

"<Node Name>" : "alphabet|<Max length>|lastName"

e.g.

"LastName" : "alphabet|20|lastName"

Output: 
"LastName": "Daniel"

date_of_birth

Use to generate random date_of_birth

Syntax:

"<Node Name>" : "date_of_birth|MinAge=<age>,MaxAge=<age>|<DateFormat>"

e.g.

"DOB" : "date_of_birth|MinAge=30,MaxAge=40|%m-%d-%Y"

Output: 
"DOB": "04-14-1981"

choices

If we want to select a value randomly from given choices

Syntax:

"<Node Name>" : "choices|(<'value1', 'value2'>)|"

e.g.

"AddressType": "choices|('RES', 'OFF', 'WRK')|"

Output: 
"AddressType": "RES"

PhoneNumber

Random Phone Number based on country

Syntax:

"<Node Name>" : "PhoneNumber||<Country Name>"

e.g.

"Mobile" : "PhoneNumber||India"

Output: 
"Mobile": "+917880010426"

email

Random Email Address

Syntax:

"<Node Name>" : "alphanum||email"

e.g.

"emailId" : "alphanum||email"

Output: 
"emailId": "ncooper@hopkins.com"

streetName

Random Street Address Name

Syntax:

"<Node Name>" : "alphabet|<length>|streetName"

e.g.

"Street-1": "alphabet|20|streetName"

Output: 
"Street-1": "Douglas Crossing"

postcode

Random postcode

Syntax:

"<Node Name>" : "numeric|<length>|postcode"

e.g.

"Postalcode": "numeric|6|postcode"

Output: 
"Postalcode": "20494"

country

Random country

Syntax:

"<Node Name>" : "alphabet||country"

e.g.

"country": "alphabet||country"

Output: 
"country": "Singapore"

city

Random city

Syntax:

"<Node Name>" : "alphabet||city"

e.g.

"City": "alphabet||city"

Output: 
"city": "Bangalore"

date

Generate Random Date between two date

Syntax:

"<Node Name>" : "date|StartDate=<date in yyyyMMdd>,EndDate=<date in yyyyMMdd>|<required Date Format>"

e.g.

"DOJ": "date|StartDate=20100223,EndDate=20200330|%Y-%m-%d"

Output: 
"DOJ": "2011-07-04"

company

Generate Random Company Name

Syntax:

"<Node Name>" : "alphabet||company"

e.g.

"Client": "alphabet||company"

Output: 
"Client": "Williams-Harris"

boolean

Randomly choose boolean value

Syntax:

"<Node Name>" : "boolean||"

e.g.

"Active": "boolean||"

Output: 
"Active": "False"

accountNumber

Generate random Basic or Internal account number

Syntax:

"<Node Name>" : "alphanum|<Account Type>|accountNumber" 
  • NONE - Generate a Basic Bank Account Number (BBAN)
  • Internal - Generate an International Bank Account Number (IBAN)

e.g.

"AccountNum": "alphanum|NONE|accountNumber"

Output: 
"AccountNum": "JRMR05894987945503"

constant

If you want to use Constant values for all the records

Syntax:

"<Node Name>" : "constant|<Required Value>|"
  • NONE - Generate a Basic Bank Account Number (BBAN)
  • Internal - Generate an International Bank Account Number (IBAN)

e.g.

"Salary": "constant|Monthly|"

Output: 
"Salary": "Monthly"

Installation

Run the following to install:

pip install dthok

Note: Python version should be >=3.6

Execution

  • Command structure to generate required bulk file,
dthok -f <input Payload file path> -n <No. of Records> -fmt <Output file format (csv, json or xml)> -o <Output file name>

For Example:

dthok -f  /test1.json -n  10 -fmt  json -o MyTestData

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

dthok-1.0.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dthok-1.0.0-py2-none-any.whl (8.1 kB view details)

Uploaded Python 2

File details

Details for the file dthok-1.0.0.tar.gz.

File metadata

  • Download URL: dthok-1.0.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for dthok-1.0.0.tar.gz
Algorithm Hash digest
SHA256 bae3b33749c60614535ff549109fc0856511a45f30bbedaad603c4b9fbc9c5d6
MD5 db6fe33be33379580a6dd96652504b5a
BLAKE2b-256 08d0a1faa4bf28f96d4be09f33ed75b38ea1331933f7b9b612e63791335fe3f6

See more details on using hashes here.

File details

Details for the file dthok-1.0.0-py2-none-any.whl.

File metadata

  • Download URL: dthok-1.0.0-py2-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for dthok-1.0.0-py2-none-any.whl
Algorithm Hash digest
SHA256 f1fd5c01437f82300990f753d781d56fb0d61cdc072b617fe6ed72feda612920
MD5 0296315697c4b4dec30a9bcf3f268097
BLAKE2b-256 1fbf11f347ded7c0080eba9a042f73cb9e3e1adf83d071c4bf1bc915b70d41c5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page