Following script is a console utility for generating test data based on provided data schema. User may create json files manually as well. Application is using argparse as a user interface for processing variety of json strings and files.
Example of CU launch with provided data_schema from cmd (“ConsoleUtility.py - pseudo name of CU):
$ python3 ConsoleUtility.py --file_count=3 --file_name=super_data --prefix=count --data_schema="{"date":
"timestamp:","name": "{rndm_uuid}", "type": "['client', 'partner', 'government']","age": "int:rand(1, 100)
"}"
Data schema from file:
$ python3 ConsoleUtility.py . --file_count=3 --file_name=super_data --prefix=count
--data_schema=./path(abs or relative)/to/schema.json
Without json or json's path being specified with --data_schema argument program will proceed to forging string with json nested inside. To do so program will create timestamp, name which is a generated uuid, random number for an age variable and type string which is either: partner, client or government.
--files_count argument take single number as a value which state how many json string will be generated by an application. Where 0 value stand for none json file being saved to file. However, in such scenario json will be printed as a logger's log only.
--file_prefix argument which may have either random, uuid, count value. It set json file prefix of the file title.
--data_lines count how many lines are saved within json file in a given path.
--clear_path verbose argument is used to clear all json files with certain name at a given path.
--file_name argument have a str value which is storing desired file name for a generated json file.
--path_to_save_files argument which holds string with either absolute or relative path where json file will be created.
Utility generate three temporary files: *config.ini for setting default values of utility args given by a user. *(generic_name).json files which store json strings. *sample.log file with logs of every operation done by an application