Package: dthok
IntroductionD-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.IndexSetupInstallation|ExecutionInput Data Typealphabets|alpha-numeric|numeric|code|title|firstName|lastName|date_of_birth|choices|PhoneNumber|email|streetName|postcode|country|city|date|company|boolean|accountNumber|constantOutput File Formatcsv|json|xmlInput DatatypeRequired input schema definition have to provided with all required Field name and required datatype in JSON format. Here is Sample input Schema definitionfile,[{"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.alphabetsTo generate random alphabetic StringSyntax:"<Node Name>":"alphabet|<length>"e.g."ProductName":"alphabet|30"alphanumTo generate random alphanumeric StringSyntax:"<Node Name>":"alphanum|<length>"e.g."ProductNumber":"alphanum|30"numericTo generate random numeric valueSyntax:"<Node Name>":"numeric|<length>"e.g."ProductID":"numeric|30"codeIf you want to generate a code with some Prefix StringSyntax:"<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 stringAt symbols (‘@’) are replaced with a random non-zero digit or an empty stringe.g."EmployeeID":"code||PALO-%%-##LTD!@"Output:"EmployeeID":"PALO-26-12LTD8"titleTo generate random salutations like Dr. or Mr. or Mrs. or Mx.Syntax:"<Node Name>":"alphabet||title"e.g."Salutation":"alphabet||title"Output:"Salutation":"Mr."firstNameUse to generate random firstNameSyntax:"<Node Name>":"alphabet|<Max length>|firstName"e.g."Firstname":"alphabet|20|firstName",Output:"Firstname":"Samantha"lastNameUse to generate random lastnameSyntax:"<Node Name>":"alphabet|<Max length>|lastName"e.g."LastName":"alphabet|20|lastName"Output:"LastName":"Daniel"date_of_birthUse to generate random date_of_birthSyntax:"<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"choicesIf we want to select a value randomly from given choicesSyntax:"<Node Name>":"choices|(<'value1', 'value2'>)|"e.g."AddressType":"choices|('RES', 'OFF', 'WRK')|"Output:"AddressType":"RES"PhoneNumberRandom Phone Number based on countrySyntax:"<Node Name>":"PhoneNumber||<Country Name>"e.g."Mobile":"PhoneNumber||India"Output:"Mobile":"+917880010426"emailRandom Email AddressSyntax:"<Node Name>":"alphanum||email"e.g."emailId":"alphanum||email"Output:"emailId":"ncooper@hopkins.com"streetNameRandom Street Address NameSyntax:"<Node Name>":"alphabet|<length>|streetName"e.g."Street-1":"alphabet|20|streetName"Output:"Street-1":"Douglas Crossing"postcodeRandom postcodeSyntax:"<Node Name>":"numeric|<length>|postcode"e.g."Postalcode":"numeric|6|postcode"Output:"Postalcode":"20494"countryRandom countrySyntax:"<Node Name>":"alphabet||country"e.g."country":"alphabet||country"Output:"country":"Singapore"cityRandom citySyntax:"<Node Name>":"alphabet||city"e.g."City":"alphabet||city"Output:"city":"Bangalore"dateGenerate Random Date between two dateSyntax:"<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"companyGenerate Random Company NameSyntax:"<Node Name>":"alphabet||company"e.g."Client":"alphabet||company"Output:"Client":"Williams-Harris"booleanRandomly choose boolean valueSyntax:"<Node Name>":"boolean||"e.g."Active":"boolean||"Output:"Active":"False"accountNumberGenerate random Basic or Internal account numberSyntax:"<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"constantIf you want to use Constant values for all the recordsSyntax:"<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"InstallationRun the following to install:pipinstalldthokNote: Python version should be >=3.6ExecutionCommand 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