Package: eaibat
Eai BATlatest update to be seen indocumentationQuick overviewBasic automation tool is mainly a python class which holds various data.It aims to ease the test's evidence creation by recording steps definition and
content in an ordered way.One goal is that class may be subclassed so that your automaton fits your needs.What's in?EaiBat class with few properties and methods.folder_file_name_cleaning package function which cleans a string from spaces and some special characters.Propertiesurl : yes it's designed to test APIs or Web application. Allowhttp,httpsandftpscheme, ASCII letters, digits and+,.and:charactershistory : your tests records in an ordered dictionary.step : your current test step. It's a length two tuple containingintorstring. It might be constructed using a Behave's Step.evidence_location :  where you store the evidence as astring.Methodspush_event: takes one event argumenta request's Response object,astringadictionarya length 2 tuple for file event. First part is the filename (relative to the evidence_folder) and the second part is the file type. Currently, only three types are managed:img,txtorsql.clear_history: without argument.create_evidence: takes two argumentsfilename: the evidence filenameevidence_type: eithermarkdownorword.Please notemarkdowngenerator is not as complete aswordgenerator.How to use it?As a standalone...Well, I don't use it as a standalone.You could create an instance of EaiBat, feed the history and then create the evidence.It may look like something as belowfromeaiBatimportEaiBatmy_reporter=EaiBat()# Set first where evidence should be storedmy_reporter.evidence_location='path_to_evidence_location'# Set the step. Mind that Behave's step do the jobmy_reporter.step=('First step','my action')# Set the history content for the stepmy_reporter.push_event("I describe what I do")# Another stepmy_reporter.step=('Second step','another action')# Another content. Mind the file will be search in the 'evidence_location'my_reporter.push_event(('screenshot.png','img'))my_reporter.push_event(('sql_file_i_processed.sql','sql'))# Create the evidencemy_reporter.create_evidence("my_evidence.docx","word")# Clear the history for a new runmy_reporter.clear_history()Part ofBehaveframeworkI prefer using this package as part ofBehavetest automation framework.Here is my usage:In the environment.py file (seeBehave's documentation)fromhelpers.modelimportMyModelfromeaiBatimportfolder_file_name_cleaningdefbefore_all(context):context.model=MyModel()context.model.url='http://my.test.environment.com'defbefore_step(context,step):context.model.step=stepdefbefore_scenario(context,scenario):context.model.evidence_location=f'evidence/{folder_file_name_cleaning(scenario.name)}'defafter_scenario(context,scenario):evidence_name=f"{scenario.name}-{scenario.status}.docx"context.model.create_evidence(folder_file_name_cleaning(evidence_name),"word")context.model.clear_history()In the helpers.model package (homemade package for the test automation) assuming I test a GUI application and I have atake_a_screeshotfunction which return the picture's filenamefromeaiBatimportEaiBatclassMyModel(EaiBat):defsome_action(self):# Action I want to reuse in my stepsself.push_event((take_a_screenshot(),'img'))In the steps definitionsfrombehaveimportGivenfromshutilimportcopy@Given('I set "{user}" user')defset_user_in_db(context,user):try:execute_sql_script(f'resources/script/{user}.sql')# Assuming you have a function executing sql scriptscontext.model.push_event(f"The{user}is in the database")copy(f'resources/script/{user}.sql',f'{context.model.evidence_location}/{user}.sql')context.model.push_event((f'{user}.sql','sql'))exceptExceptionasexception:context.model.push_event(f"The step has failed due to{exception.args}")