def start_launch(self,
                     launch_name,
                     mode=None,
                     description=None,
                     attributes=None,
                     **kwargs):
        """
        Launch test items.

        :param launch_name: name of the launch
        :param mode:        mode
        :param description: description of launch test
        :param kwargs:      additional params
        :return: item ID
        """
        self._stop_if_necessary()
        if self.rp is None:
            return

        sl_pt = {
            'attributes': self._get_launch_attributes(attributes),
            'name': launch_name,
            'start_time': timestamp(),
            'description': description,
            'mode': mode,
        }
        log.debug('ReportPortal - Start launch: request_body=%s', sl_pt)
        item_id = self.rp.start_launch(**sl_pt)
        log.debug('ReportPortal - Launch started: id=%s', item_id)
        if not self._skip_analytics:
            send_event(self.agent_name, self.agent_version)
        return item_id
def test_send_event(mocked_distribution, mocked_requests):
    """Test functionality of the send_event() function.

    :param mocked_distribution: Mocked get_distribution() function
    :param mocked_requests:     Mocked requests module
    """
    expected_cl_version, expected_cl_name = '5.0.4', 'reportportal-client'
    agent_version, agent_name = '5.0.5', 'pytest-reportportal'
    mocked_distribution.return_value.version = expected_cl_version
    mocked_distribution.return_value.project_name = expected_cl_name

    expected_headers = {'User-Agent': 'Universal Analytics'}

    expected_data = {
        'v': '1',
        'tid': GA_INSTANCE,
        'aip': '1',
        'cid': '555',
        't': 'event',
        'ec': 'Client name "{}", version "{}"'.format(
            expected_cl_name, expected_cl_version
        ),
        'ea': 'Start launch',
        'el': 'Agent name "{}", version "{}"'.format(
            agent_name, agent_version
        )
    }
    send_event(agent_name, agent_version)
    mocked_requests.assert_called_with(
        url=GA_ENDPOINT, data=expected_data, headers=expected_headers)
Exemple #3
0
    def start_launch(self,
                     launch,
                     mode=None,
                     rerun=False,
                     rerun_of=None,
                     ts=None,
                     skip_analytics=False):
        """Call start_launch method of the common client.

        :param launch:         Instance of the Launch class
        :param mode:           Launch mode
        :param rerun:          Rerun mode. Allowable values 'True' of 'False'
        :param rerun_of:       Rerun mode. Specifies launch to be re-runned.
                               Should be used with the 'rerun' option.
        :param ts:             Start time
        :param skip_analytics: Skip reporting of agent name and version to GA?
        :return:               launch UUID
        """
        sl_pt = {
            'attributes': self._get_launch_attributes(launch.attributes),
            'description': launch.doc,
            'name': launch.name,
            'mode': mode,
            'rerun': rerun,
            'rerunOf': rerun_of,
            'start_time': ts or to_epoch(launch.start_time) or timestamp()
        }
        logger.debug(
            'ReportPortal - Start launch: request_body={0}'.format(sl_pt))
        if not skip_analytics:
            send_event(self.agent_name, self.agent_version)
        return self.rp.start_launch(**sl_pt)
 def start_launch(self, context, **kwargs):
     """Start launch in Report Portal."""
     self._launch_id = self._rp.launch_id or self._rp.start_launch(
         name=self._cfg.launch_name,
         start_time=timestamp(),
         attributes=self._get_launch_attributes(),
         description=self._cfg.launch_description,
         rerun=self._cfg.rerun,
         rerunOf=self._cfg.rerun_of,
         **kwargs)
     if not self._skip_analytics:
         send_event(self.agent_name, self.agent_version)
Exemple #5
0
    def start_launch(self):
        """
        Launch test items.

        :return: item ID
        """
        if self.rp is None:
            return
        sl_pt = self._build_start_launch_rq()
        log.debug('ReportPortal - Start launch: request_body=%s', sl_pt)
        self._launch_id = self.rp.start_launch(**sl_pt)
        log.debug('ReportPortal - Launch started: id=%s', self._launch_id)
        if not self._skip_analytics:
            send_event(self.agent_name, self.agent_version)
        return self._launch_id
    def start_launch(self, launch, mode=None, ts=None, skip_analytics=False):
        """Call start_launch method of the common client.

        :param launch:         Instance of the Launch class
        :param mode:           Launch mode
        :param ts:             Start time
        :param skip_analytics: Skip reporting of agent name and version to GA?
        :return:               launch UUID
        """
        sl_pt = {
            'attributes': self._get_launch_attributes(launch.attributes),
            'description': launch.doc,
            'name': launch.name,
            'mode': mode,
            'start_time': ts or to_epoch(launch.start_time) or timestamp()
        }
        logger.debug(
            'ReportPortal - Start launch: request_body={0}'.format(sl_pt))
        if not skip_analytics:
            send_event(self.agent_name, self.agent_version)
        return self.rp.start_launch(**sl_pt)
    def start_launch(launch_name,
                     attributes=None,
                     description=None,
                     mode=None):
        """Call start_launch method of the common client.

        :param launch_name: Launch name
        :param attributes:  Launch attributes
        :param description: Launch description
        :param mode:        Launch mode
        :return:            launch UUID
        """
        sl_pt = {
            "attributes": RobotService._get_launch_attributes(attributes),
            "name": launch_name,
            "start_time": timestamp(),
            "description": description,
            "mode": mode
        }
        logging.debug("ReportPortal - Start launch: "
                      "request_body={0}".format(sl_pt))
        if not Variables.skip_analytics:
            send_event(RobotService.agent_name, RobotService.agent_version)
        return RobotService.rp.start_launch(**sl_pt)
def test_send_event_raises():
    """Test that the send_event() does not raise exceptions."""
    send_event('pytest-reportportal', '5.0.5')