예제 #1
0
    def send_test_case_chart(self, chart_info, iteration=False):
        """
        Attach a chart to the current test case

        :param dict chart_info: data to build the chart on the server (title, series, axis ...)
        :param bool iteration (optional): True if the test case has at least two iterations
        """
        if self._tcr_instance:
            # Push a resource to TCR Reporting tool via REST API interface (Test case level)
            self._tcr_instance.send_testcase_chart(chart_info,
                                                   iteration=iteration)
        else:
            LOGGER_FWK.warning('Only TCR offers REST API for charts!')
예제 #2
0
def timezone():
    """
    Return host timezone

    :rtype: str
    :return: Timezone (i.e: 'Europe/Paris')
    """
    # Trying to get local timezone
    try:
        import tzlocal
        host_localtimezone = str(tzlocal.get_localzone())
    except Exception as tzlocal_exception:
        # Set default host time
        host_localtimezone = DEFAULT_TIMEZONE
        LOGGER_FWK.warning("Cannot get host timezone ! "
                           "Use default timezone ('{0}') => {1}".format(
                               host_localtimezone, str(tzlocal_exception)))
    return host_localtimezone
예제 #3
0
    def update_report_file(self):
        """
        Update the xml report file
        """
        try:

            temp_test_report_file = os.path.join(tempfile.gettempdir(), "Temporary_TestReport.xml")
            processing_instruction = etree.ProcessingInstruction(
                "xml-stylesheet", "type=\"text/xsl\" href=\"report.xsl\"")
            with open(temp_test_report_file, 'w') as f_test_report:
                f_test_report.write(etree.tostring(processing_instruction, pretty_print=True, xml_declaration=True))
                f_test_report.write(etree.tostring(self.document, pretty_print=True))

            # Copy the temporary file into the test report
            shutil.move(temp_test_report_file, self.filename)
            # copy the XSL file in the same folder ad the XML file
            shutil.copy(self._xsl_path, self._base)

        except Exception as report_exception:
            LOGGER_FWK.warning("Fail to update test report '%s' ! (%s)" % (str(self.filename), str(report_exception)))
예제 #4
0
    def _override_parameters_bench(self):
        """
        Override device config with device parameters available in bench config if applicable.

        """
        device_model_name = self.device_model_name
        device_name = self._device_name

        if self.bench_conf:
            do_the_override = False
            if device_name == AcsConstants.DEFAULT_DEVICE_NAME:
                if "Name" not in self.bench_conf:
                    # No device specified in the bench config for PHONE1
                    # Do the override then
                    do_the_override = True
                elif self.bench_conf.Name == device_model_name:
                    # Same device specified on the command line then in the bench config
                    # Do the override
                    do_the_override = True
                else:
                    warning_msg = (
                        "Different device model specified on the command line ({0}) "
                        "then in the bench config ({1}) for {2}! Related parameters specified "
                        "in bench config will be ignored !").format(
                            device_model_name, self.bench_conf.Name,
                            AcsConstants.DEFAULT_DEVICE_NAME)
                    LOGGER_FWK.warning(warning_msg)
            else:
                # For other phones (PHONE2, ...) we do the override every time
                do_the_override = True

            if do_the_override:
                for key, value in self.bench_conf.iteritems():
                    if key == "device_modules":
                        for module, module_conf in value.iteritems():
                            self.device_conf.device_modules[
                                module] = module_conf
                    else:
                        self._override_through_sections(
                            self.device_conf, key, value,
                            self._bench_unknown_parameters)
예제 #5
0
    def send_campaign_resource(self, campaign_uuid, resource_info):
        """
        Push a resource onto (TCR Only) REST API for a given Test Case.

        :param dict campaign_uuid: id of the campaign.
        :param dict resource_info: Local resource to be pushed onto TCR at Test Case level.
        """
        if self._tcr_instance:
            # Archive file to push
            context_dict = {
                "acs_logfile_name": Files.acs_output_name,
                "TCR_LIVE_REPORTING": REPORT_FILE_NAME,
                "ROOT_DUT_NAME": Folders.ROOT_DUT_NAME,
                "AP_LOGS": Folders.AP_LOGS,
                "BP_LOGS": Folders.BP_LOGS,
                "PTI_LOGS": Folders.PTI_LOGS,
                "SERIAL_LOGS": Folders.SERIAL_LOGS,
                "LOGCAT_LOGS": Folders.LOGCAT_LOGS,
                "DEBUG_LOGS": Folders.DEBUG_LOGS,
                "REPORT_STYLE_FILENAME": Files.REPORT_STYLE
            }
            tcr_push = TCRpush(
                original_acs_report=resource_info["campaign_report_path"],
                metacampaign_uuid=campaign_uuid,
                user_mail=resource_info["user_email"],
                cache_reports=Paths.CACHE_PUSH_REPORTS,
                dev_campaign=resource_info["dev_campaign"],
                log_folders_and_files=context_dict)
            # Build archive to push
            status, msg = tcr_push.setup()
            if status == Global.SUCCESS:
                # Push a resource to TCR Reporting tool via REST API interface (Test case level)
                self._tcr_instance.send_campaign_resource(
                    resource=tcr_push.zip_acs_report_tcr)
            else:
                LOGGER_FWK.error(
                    "Error when building campaign result archive! {}".format(
                        msg))
        else:
            LOGGER_FWK.warning('Only TCR offers REST API for resources!')
예제 #6
0
    def send_test_case_resource(self,
                                resource,
                                display_name=None,
                                retention="SHORT",
                                iteration=False):
        """
        Push a resource onto (TCR Only) REST API for a given Test Case.

        :param str resource: Local resource to be pushed onto TCR at Test Case level.
        :param str display_name: (optional) Filename to be displayed in the UI
        :param str retention: (optional) "SHORT" or "LONG"
        :param bool iteration: (optional) True if the test case has at least two iterations

        """
        if self._tcr_instance:
            # Push a resource to TCR Reporting tool via REST API interface (Test case level)
            self._tcr_instance.send_testcase_resource(
                resource,
                display_name=display_name,
                retention=retention,
                iteration=iteration)
        else:
            LOGGER_FWK.warning('Only TCR offers REST API for resources!')