def append_result(self, tc_file=None): """ Append a new fully constructed Result to the internal ResultList. :param tc_file: Test case file path :return: Nothing """ result = Result() result.set_tc_metadata(self._configuration.config) tc_rev = get_git_info(self._configuration.get_tc_abspath(tc_file), verbose=self._args.verbose) if self._logger: self._logger.debug(tc_rev) result.set_tc_git_info(tc_rev) result.component = self._configuration.get_test_component() result.feature = self._configuration.get_features_under_test() result.skip_reason = self._configuration.skip_reason() if self._configuration.skip() else '' result.fail_reason = self._failreason result.logpath = os.path.abspath(LogManager.get_base_dir()) result.logfiles = LogManager.get_logfiles() result.retcode = self.retcode result.set_dutinformation(self._resources.dutinformations) # pylint: disable=unused-variable for platform, serialnumber in zip(self._resources.get_platforms(), self._resources.get_serialnumbers()): # Zipping done to keep platforms and serial numbers aligned in case some sn:s are # missing result.dut_vendor.append('') result.dut_resource_id.append(serialnumber) result.dut_count = self._resources.get_dut_count() result.duts = self._resources.resource_configuration.get_dut_configuration() if self._resources.resource_configuration.count_hardware() > 0: result.dut_type = 'hw' elif self._resources.resource_configuration.count_process() > 0: result.dut_type = 'process' else: result.dut_type = None self._result_list.append(result)
def test_cloudresult_full(self): test_res = { "testcase": "tc_name", "verdict": "fail", "reason": "ohnou", "retcode": 0, "duration": 1, "fw_name": "Icetea", "fw_version": "0.10.2" } result = Result(test_res) class DummyBuild(object): @property def branch(self): return 'master' @property def commit_id(self): return '1234' @property def build_url(self): return 'url' @property def giturl(self): return 'url' @property def date(self): return "22.22.2222" @property def sha1(self): return "asdv" class DummyDut(object): @property def resource_id(self): return '123' @property def platform(self): return 'K64F' @property def build(self): return DummyBuild() result.set_dutinformation([DummyDut()]) res = create_result_object(result) compare = { 'exec': { 'verdict': 'pass', 'note': 'ohnou', 'duration': 1, 'env': { 'framework': { 'ver': '0.10.2', 'name': 'Icetea' } }, 'sut': { 'commitId': '1234', 'buildUrl': 'url', 'gitUrl': 'url', 'branch': 'master', "buildDate": "22.22.2222", "buildSha1": "asdv" }, 'dut': { 'sn': '123', 'model': 'K64F' } }, 'tcid': 'tc_name' } self.assertDictContainsSubset(compare, res)