Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def _finalize_test_case_from_verdict(test_group: str, verdicts: data_parser.TestCaseFinalization, test_case: data_storage.TestCase, info_for_txn: data_storage.TransactionInformation = None):
- """
- Attempts to finalize a test case that either completed OK or terminated abnormally somewhere
- Input : data required for finalizing, see types above
- Return : None
- Date Who ISsue & Comment
- xxxx.xx.xx ArtursA (REBVATS-732) Function created
- xxxx.xx.xx ArtursA (REBVATS-1096) Moved data related to reports generation to a separate method.
- xxxx.xx.xx ArtursA (REBVATS-1096) Moved logic that handles BTT verdict here
- 2016.11.08 IvarsG (REBVATS-1363) Added more detailed info if verdict is OK but VATS still has fails.
- 2016.11.10 ArtursA1 (REBVATS-1346) Added test_group field
- 2016.11.09 IvarsG (REBVATS-1353) Added "non_automatable" verdict outcome handling.
- 2017.01.11 IgorsB (REBVATS-1544) Added verdicts and test_case None type validation
- """
- was_failed = True
- verdict_header = "BTT Verdict: "
- result_for_zephyr = None
- if verdicts is None:
- user_message_centered("TEST CASE FAILED")
- user_message_centered("NO VERDICT FROM BTT - Check data that has been sent to BTT")
- ats_addons.set_failure_reason("No verdict received from BTT")
- result_for_zephyr = 2
- elif verdicts.outcome == "non_automatable":
- user_message_centered("TEST CASE NON AUTOMATABLE")
- verdict_header = ats_addons.BLOCKED_STATUS_TEXT + ": "
- was_failed = False
- result_for_zephyr = 2
- elif not info_for_txn:
- user_message_centered("TEST CASE FAILED")
- user_message_centered("TRANSACTION INFO NOT SUPPLIED. CONSULT BTT LOGS")
- result_for_zephyr = 2
- elif verdicts.outcome not in ["passed", "inconclusive"]:
- user_message_centered("TEST CASE FAILED")
- user_message_centered("DATA REQUESTED WAS:" + str(info_for_txn.requested_data))
- result_for_zephyr = 2
- else:
- user_message_centered("TEST CASE PASSED")
- if ats._ats__check_fails > 0:
- ats_addons.set_failure_reason(". VATS check fail count before reset: " + str(ats._ats__check_fails))
- ats._ats__check_fails = 0
- was_failed = False
- result_for_zephyr = 1
- if verdicts is not None and test_case is not None:
- _make_reports_entry(verdict_header + verdicts.outcome, test_case.get_readable_name(), test_case.get_readable_test_plan(), test_group, was_failed)
- else:
- LOG("Got NoneType object: verdicts = "+str(verdicts)+" | test_case = "+str(test_case))
- return result_for_zephyr
- def _run_test_case(test_group: str, test_case: data_storage.TestCase, brand):
- """
- Method that runs an individual test case from start to finish and leaves the automation server in a
- state where it can perform new test cases
- Input : test_case - test case to be run
- : brand - card brand to which this test case belongs
- : test_group - theoretical "test group" that this test belongs to.
- Return : verdicts
- Date Who Issue & Comment
- xxxx.xx.xx ArtursA (REBVATS-732) Function created
- xxxx.xx.xx ArtursA (REBVATS-899) Split param handling logic away from InfoForFosVats constructor, added call to new method
- xxxx.xx.xx ArtursA (REBVATS-1096) Removed handling in case no response.
- 2016.11.08 IvarsG (REBVATS-1354) Moved global flag clearance before this function call.
- 2016.11.09 IvarsG (REBVATS-1353) Added test case finalization handling in response on test case initialization.
- """
- get_user().back_to_main_menu()
- verdicts = None
- info_for_txn = None
- response, verdicts = btt_protocol_base.initiate_test_case(brand, *test_case.get_data_for_initiate_transaction())
- if verdicts is None:
- while response.get("message_type") == "Initiate Transaction":
- info_for_txn = data_storage.TransactionInformation()
- info_for_txn.parse_transaction_information(response)
- info_for_txn.test_case_name = test_case.get_readable_name()
- info_for_txn.brand = brand
- if data_storage.TransactionInformationBackup.transaction_count > 0:
- data_storage.TransactionInformationBackup.get_amounts(info_for_txn)
- test_case.assign_transaction_info(info_for_txn)
- verdicts, response = _do_transaction(info_for_txn, test_case)
- data_storage.TransactionInformationBackup.transaction_count = 0
- result_for_zephyr =_finalize_test_case_from_verdict(test_group, verdicts, test_case, info_for_txn)
- LOG("Sending status of test to Zefir...")
- test_case_issue_id = zefir.is_test_case_on_list(test_case)
- zefir.execute_issue_in_zephyr(test_case_issue_id, result_for_zephyr)
- print ("Status for given testcase sent to Zefir")
- return verdicts
- def run_test_cases(brand, interface, list_of_test_cases):
- """
- Main runner function for BTT Automation
- Input : brand - card brand for which the test case will be initiated
- :type list_of_test_cases: list[data_storage.TestCase]
- Return : N/A
- Date Who Issue & Comment
- xxxx.xx.xx ArtursA (REBVATS-732) Function created
- xxxx.xx.xx ArtursA (REBVATS-1096) Added specific handling for Invalid BTT message exceptions.
- xxxx.xx.xx ArtursA (REBVATS-1096) Set outcome status when making report entry.
- xxxx.xx.xx ArtursA (REBVATS-1113) Add MCCLIST to files to activate, MCC will be used to route txn to host sim.
- xxxx.xx.xx ArtursA (REBVATS-992) Added log splitting logic.
- 2016.08.25 ArtursA (REBVATS-1156) Moved logfile splitting to on_test_cycle_end
- 2016.09.13 IgorsB (REBVATS-935) Added CFG_RUN_BTT_AUTOMATION setting and removing
- 2016.09.21 IgorsB (REBVATS-1181) Added test case searching in blocked list, added blocked test case adding into report with corresponding type and reason
- 2016.11.08 IvarsG (REBVATS-1354) Moved global flag clearance here to make sure they are always cleared.
- 2016.11.10 ArtursA1 (REBVATS-1346) Added setting of test_group
- 2016.12.09 IgorsB (REBVATS-1198) Added blocked test cases list getting
- 2016.12.12 ArtursA1 (REBVATS-1487) Initialize values for limit enums
- 2016.12.21 ArtursA1 (REBVATS-1420) Reworked how "blocked" test cases work
- 2017.01.16 IvarsG (REBVATS-1521) Added current interface as log file prefix.
- 2017.01.23 IvarsG (REBVATS-1521) Added interface covertion to upper to match common style.
- """
- get_helpers().prepare_terminal_for_btt_tests()
- # We have no intention of using the Card Simulator server here, update config to reflect that
- original_cssp_status = get_config_value(CFG_USE_COLLIS)
- set_config_value(CFG_USE_COLLIS, CFG_OFF)
- set_config_value(CFG_USE_BTT_AUTOMATION, CFG_ON)
- total_test_cases = len(list_of_test_cases)
- current_test_case = 0
- test_group = utils.format_brand_and_interface(brand, interface)
- global_modules.transaction_limits.initialize_all(brand)
- for test_case in list_of_test_cases:
- ats._ats__check_passes = 0
- ats._ats__check_fails = 0
- ats_addons.clear_all_failure_reasons()
- ats_addons.script_start_time = perf_counter()
- current_test_case += 1
- test_case_name = test_case.get_readable_name()
- log_helpers.log_test_case_start_to_log_system(utils.get_log_file_prefix(interface).upper(), test_case_name, current_test_case, total_test_cases)
- test_case_blocked, blocked_reason = btt_automation.blocked_test_list.is_test_case_blocked(test_case, brand)
- if not test_case_blocked:
- try:
- _run_test_case(test_group, test_case, brand)
- except btt_protocol_base.BttInvalidMessageError as error:
- LOG(str(error) + ". Detailed: " + error.get_detailed_error_text())
- _make_reports_entry(str(error), test_case_name, test_case.get_readable_test_plan(), test_group, True, )
- btt_protocol_base.terminate_testing()
- except Exception as e:
- _make_reports_entry("Terminated abnormally! [{0}]".format(e), test_case_name, test_case.get_readable_test_plan(), test_group, True)
- btt_protocol_base.terminate_testing()
- LOG(get_exception_string())
- else:
- user_message_centered("TEST CASE BLOCKED - " + blocked_reason)
- _make_reports_entry(ats_addons.BLOCKED_STATUS_TEXT + " - " + blocked_reason, test_case_name, test_case.get_readable_test_plan(), test_group, False)
- log_helpers.log_test_case_end_to_log_system(utils.get_log_file_prefix(interface).upper(), test_case_name)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement