Log

class tir.technologies.core.log.Log(suite_datetime='', user='', station='', program='', program_date='19800101', version='', release='', database='', issue='', execution_id='', country='', folder='', test_type='TIR', config_path='')

This class is instantiated to create the log file and to append the results and failures to it.

Usage:

>>> # Instanted inside base.py:
>>> self.log = Log()
checks_empty_line()

Checks if the log file is not empty. 03 - ‘Programa’ 10 - ‘Release’ 14 - ‘ID Execução’ 15 - ‘Pais’ [Internal]

generate_dict(result, message)

Returns a dictionary with the log information

generate_header()

Generates the header line on the log file.

Usage:

>>> # Calling the method:
>>> self.log.generate_header()
generate_json(dictionary)
generate_result(result, message)

Generate a result of testcase and export to a json.

Parameters:
  • result (bool) – The result of the case.

  • message (str) – The message to be logged..

Usage:

>>> # Calling the method:
>>> self.log.generate_result(True, "Success")
get_file_name(file_name)

Returns a Testsuite name

get_program_name()

[Internal]

get_testcase_stack()

Returns a string with the current testcase name [Internal]

ident_test()
Returns:

list_of_testcases()

Returns a list of test cases from suite

log_exec_file()

[Internal]

new_line(result, message)

Appends a new line with data on log file.

Parameters:
  • result (bool) – The result of the case.

  • message (str) – The message to be logged..

Usage:

>>> # Calling the method:
>>> self.log.new_line(True, "Success")
printable_message(string)
Parameters:

string

Returns:

save_file()

Writes the log file to the file system.

Usage:

>>> # Calling the method:
>>> self.log.save_file()
save_json_file(json_data)

Writes the log file to the file system.

Usage:

>>> # Calling the method:
>>> self.log.save_json_file()
save_response_log(response, server_address, json_data)
screenshot_file_name(description='', stack_item='')
Parameters:

name

Returns:

search_stack(function)

Returns True if passed function is present in the call stack.

Parameters:

function (str) – Name of the function

Returns:

Boolean if passed function is present or not in the call stack.

Return type:

bool

Usage:

>>> # Calling the method:
>>> is_present = self.search_stack("MATA020")
send_request(server_address, json_data)

Send a post request to server

set_seconds(initial_time)

Sets the seconds variable through a calculation of current time minus the execution start time.

Usage:

>>> # Calling the method:
>>> self.log.set_seconds()
take_screenshot_log(driver, description='', stack_item='', test_number='')

[Internal]

Takes a screenshot and saves on the log screenshot folder defined in config.

Parameters:
  • driver – The selenium driver.

  • stack_item – test case stack

  • test_number – test case number

Type:

Selenium Driver

Type:

str

Type:

str

Usage:

>>> # Calling the method:
>>> self.log.take_screenshot_log()