def _extract_scenario_from_soapui(self, base_scenario, script_path): test_case = base_scenario.get("test-case", None) converter = SoapUIScriptConverter(self.log) conv_config = converter.convert_script(script_path) conv_scenarios = conv_config["scenarios"] scenario_name, conv_scenario = converter.find_soapui_test_case( test_case, conv_scenarios) new_name = scenario_name counter = 1 while new_name in self.engine.config["scenarios"]: new_name = scenario_name + ("-%s" % counter) counter += 1 if new_name != scenario_name: self.log.info( "Scenario name '%s' is already taken, renaming to '%s'", scenario_name, new_name) scenario_name = new_name merged_scenario = BetterDict.from_dict(conv_scenario) merged_scenario.merge(base_scenario.data) for field in [Scenario.SCRIPT, "test-case"]: if field in merged_scenario: merged_scenario.pop(field) return scenario_name, merged_scenario
def test_find_test_case(self): obj = SoapUIScriptConverter(ROOT_LOGGER) config = obj.convert_script(RESOURCES_DIR + "soapui/project.xml") scenarios = config["scenarios"] self.assertEqual(len(scenarios), 4) target_scenario = scenarios["TestSuite 1-index"] found_name, found_scenario = obj.find_soapui_test_case("index", scenarios) self.assertEqual(target_scenario, found_scenario)
def test_find_test_case_empty(self): obj = SoapUIScriptConverter(ROOT_LOGGER) self.sniff_log(obj.log) config = obj.convert_script(RESOURCES_DIR + "soapui/project.xml") scenarios = config["scenarios"] self.assertEqual(len(scenarios), 4) target_scenario = scenarios["BlazeDemo LoadTest"] found_name, found_scenario = obj.find_soapui_test_case(None, scenarios) self.assertEqual(target_scenario, found_scenario)
def test_find_test_case_empty(self): obj = SoapUIScriptConverter(ROOT_LOGGER) self.sniff_log(obj.log) config = obj.convert_script(RESOURCES_DIR + "soapui/project.xml") scenarios = config["scenarios"] self.assertEqual(len(scenarios), 3) target_scenario = scenarios["TestSuite 1-index"] found_name, found_scenario = obj.find_soapui_test_case(None, scenarios) self.assertEqual(target_scenario, found_scenario) self.assertIn("No `test-case` specified for SoapUI project, will use 'index'", self.log_recorder.warn_buff.getvalue())