def test_func_reader(self): reader = FuncSamplesReader(RESOURCES_DIR + "selenium/report.ldjson", EngineEmul(), ROOT_LOGGER) items = list(reader.read()) self.assertEqual(4, len(items)) self.assertEqual(items[0].test_case, 'testFailure') self.assertEqual(items[0].status, "FAILED") self.assertEqual(items[1].test_case, 'testBroken') self.assertEqual(items[1].status, "BROKEN") self.assertEqual(items[2].test_case, 'testSuccess') self.assertEqual(items[2].status, "PASSED")
def test_func_reader(self): reader = FuncSamplesReader(__dir__() + "/../../resources/selenium/report.ldjson", EngineEmul(), logging.getLogger(), None) items = list(reader.read()) self.assertEqual(4, len(items)) self.assertEqual(items[0].test_case, 'testFailure') self.assertEqual(items[0].status, "FAILED") self.assertEqual(items[1].test_case, 'testBroken') self.assertEqual(items[1].status, "BROKEN") self.assertEqual(items[2].test_case, 'testSuccess') self.assertEqual(items[2].status, "PASSED")
def test_func_reader(self): reader = FuncSamplesReader(RESOURCES_DIR + "selenium/report.ldjson", EngineEmul(), ROOT_LOGGER) items = list(reader.read()) self.assertEqual(4, len(items)) self.assertEqual(items[0].test_case, 'testFailure') self.assertEqual(items[0].status, "FAILED") self.assertEqual(items[1].test_case, 'testBroken') self.assertEqual(items[1].status, "BROKEN") self.assertEqual(items[2].test_case, 'testSuccess') self.assertEqual(items[2].status, "PASSED")
def test_report_reading(self): reader = FuncSamplesReader(__dir__() + "/../../resources/apiritif/transactions.ldjson", self.obj.engine, self.obj.log, []) items = list(reader.read(last_pass=True)) self.assertEqual(len(items), 6) self.assertEqual(items[0].test_case, "test_1_single_request") self.assertEqual(items[1].test_case, "test_2_multiple_requests") self.assertEqual(items[2].test_case, "Transaction") self.assertEqual(items[3].test_case, "Transaction") self.assertEqual(items[4].test_case, "Transaction 1") self.assertEqual(items[5].test_case, "Transaction 2")
def test_report_reading(self): reader = FuncSamplesReader(RESOURCES_DIR + "apiritif/transactions.ldjson", self.obj.engine, self.obj.log) items = list(reader.read(last_pass=True)) self.assertEqual(9, len(items)) self.assertEqual(items[0].get_short_name(), 'TestRequests.test_1_single_request') self.assertEqual(items[1].get_short_name(), 'TestRequests.test_2_multiple_requests') self.assertEqual(items[2].get_short_name(), 'test_3_toplevel_transaction.Transaction') self.assertEqual(items[3].get_short_name(), 'test_4_mixed_transaction.Transaction') self.assertEqual(items[4].get_short_name(), 'test_5_multiple_transactions.Transaction 1') self.assertEqual(items[5].get_short_name(), 'test_5_multiple_transactions.Transaction 2') self.assertEqual(items[6].get_short_name(), 'test_6_transaction_obj.Label') self.assertEqual(items[7].get_short_name(), 'test_7_transaction_fail.Label') self.assertEqual(items[8].get_short_name(), 'test_8_transaction_attach.Label')
def test_report_reading(self): reader = FuncSamplesReader(RESOURCES_DIR + "apiritif/transactions.ldjson", self.obj.engine, self.obj.log) items = list(reader.read(last_pass=True)) self.assertEqual(9, len(items)) self.assertEqual(items[0].get_short_name(), 'TestRequests.test_1_single_request') self.assertEqual(items[1].get_short_name(), 'TestRequests.test_2_multiple_requests') self.assertEqual(items[2].get_short_name(), 'test_3_toplevel_transaction.Transaction') self.assertEqual(items[3].get_short_name(), 'test_4_mixed_transaction.Transaction') self.assertEqual(items[4].get_short_name(), 'test_5_multiple_transactions.Transaction 1') self.assertEqual(items[5].get_short_name(), 'test_5_multiple_transactions.Transaction 2') self.assertEqual(items[6].get_short_name(), 'test_6_transaction_obj.Label') self.assertEqual(items[7].get_short_name(), 'test_7_transaction_fail.Label') self.assertEqual(items[8].get_short_name(), 'test_8_transaction_attach.Label')
def reporting_setup(self, prefix=None, suffix=None): if not self.reported: self.log.debug("Skipping reporting setup for executor %s", self) return if "report-file" in self.execution: self.report_file = self.execution.get("report-file") else: if not prefix: prefix = self.__class__.__name__ if suffix is None: suffix = '.dat' self.report_file = self.engine.create_artifact(prefix, suffix) self.report_file = self.report_file.replace(os.path.sep, '/') if not self.register_reader: self.log.debug("Skipping reader setup for executor %s", self) return if self.engine.is_functional_mode(): self.reader = FuncSamplesReader(self.report_file, self.engine, self.log) if isinstance(self.engine.aggregator, FunctionalAggregator): self.engine.aggregator.add_underling(self.reader) else: self.reader = LoadSamplesReader(self.report_file, self.log) if isinstance(self.engine.aggregator, ConsolidatingAggregator): self.engine.aggregator.add_underling(self.reader)
def startup(self): """ run python tests """ executable = self.settings.get("interpreter", sys.executable) if "report-file" in self.execution: report_file = self.execution.get("report-file") else: report_file = self.engine.create_artifact("report", ".ldjson") if self.engine.is_functional_mode(): self.reader = FuncSamplesReader(report_file, self.engine, self.log, []) if isinstance(self.engine.aggregator, FunctionalAggregator): self.engine.aggregator.add_underling(self.reader) else: self.reader = LoadSamplesReader(report_file, self.log, []) if isinstance(self.engine.aggregator, ConsolidatingAggregator): self.engine.aggregator.add_underling(self.reader) nose_command_line = [ executable, self.plugin_path, '--report-file', report_file ] load = self.get_load() if load.iterations: nose_command_line += ['-i', str(load.iterations)] if load.hold: nose_command_line += ['-d', str(load.hold)] nose_command_line += [self._script] self._start_subprocess(nose_command_line)
def reporting_setup(self, prefix=None, suffix=None, translation_table=None): if not self.reported: return if translation_table is None: translation_table = {} if "report-file" in self.execution: self.report_file = self.execution.get("report-file") else: if not prefix: prefix = self.__class__.__name__ if suffix is None: suffix = '.dat' self.report_file = self.engine.create_artifact(prefix, suffix) self.report_file = self.report_file.replace(os.path.sep, '/') if self.engine.is_functional_mode(): self.reader = FuncSamplesReader(self.report_file, self.engine, self.log, translation_table) if isinstance(self.engine.aggregator, FunctionalAggregator): self.engine.aggregator.add_underling(self.reader) else: self.reader = LoadSamplesReader(self.report_file, self.log, translation_table) if isinstance(self.engine.aggregator, ConsolidatingAggregator): self.engine.aggregator.add_underling(self.reader)
def _register_reader(self, report_file): if self.engine.is_functional_mode(): reader = FuncSamplesReader(report_file, self.engine, self.log, self.generated_methods) if isinstance(self.engine.aggregator, FunctionalAggregator): self.engine.aggregator.add_underling(reader) else: reader = LoadSamplesReader(report_file, self.log, self.generated_methods) if isinstance(self.engine.aggregator, ConsolidatingAggregator): self.engine.aggregator.add_underling(reader) return reader
def test_status_skipped(self): self.configure({ "execution": [{ "iterations": 1, "scenario": { "script": RESOURCES_DIR + "functional/test_all.py" } }] }) self.obj.prepare() try: self.obj.startup() while not self.obj.check(): time.sleep(self.obj.engine.check_interval) finally: self.obj.shutdown() self.obj.post_process() reader = FuncSamplesReader(self.obj.report_file, self.obj.engine, self.obj.log) samples = list(reader.read(last_pass=True)) self.assertEqual(len(samples), 4) self.assertIsNotNone(samples[-1].status)
def test_status_skipped(self): self.configure({ "execution": [{ "iterations": 1, "scenario": { "script": RESOURCES_DIR + "functional/test_all.py" } }] }) self.obj.engine.aggregator = FunctionalAggregator() self.obj.prepare() try: self.obj.startup() while not self.obj.check(): time.sleep(self.obj.engine.check_interval) finally: self.obj.shutdown() self.obj.post_process() reader = FuncSamplesReader(os.path.join(self.obj.engine.artifacts_dir, "apiritif.0.ldjson"), self.obj.engine, self.obj.log) samples = list(reader.read(last_pass=True)) self.assertEqual(len(samples), 4) self.assertIsNotNone(samples[-1].status)
def create_func_reader(self, report_file): return FuncSamplesReader(report_file, self.engine, self.log)