Ejemplo n.º 1
0
    def test_limited_retry_sender_other_exception(self):
        mock_url_open = mock.Mock()
        mock_url_open.side_effect = ValueError('error')

        with mock.patch.object(http_client_t, 'urlopen', mock_url_open):
            sender = _NoRetrySender()
            sender.send(self.sample_data[0])

        mock_url_open.assert_called_once()
Ejemplo n.º 2
0
    def test_limited_retry_sender_other_exception(self):
        mock_url_open = mock.Mock()
        mock_url_open.side_effect = ValueError('error')

        with mock.patch.object(http_client_t, 'urlopen', mock_url_open):
            sender = _NoRetrySender()
            sender.send(self.sample_data[0])

        mock_url_open.assert_called_once()
Ejemplo n.º 3
0
    def test_limited_retry_sender(self):
        mock_url_open = mock.Mock()

        with mock.patch.object(http_client_t, 'urlopen', mock_url_open):
            sender = _NoRetrySender()
            sender.send(self.sample_data[0])

        mock_url_open.assert_called_once()
        args, kwargs = mock_url_open.call_args

        self.assertEqual(10, kwargs['timeout'])

        data = json.loads(args[0].data.decode('utf-8'))[0]
        self.assertEqual('Microsoft.ApplicationInsights.Event', data['name'])
        self.assertEqual('UserTask', data['data']['baseData']['properties']['Reserved.DataModel.EntityType'])
        self.assertEqual('azurecli', data['data']['baseData']['properties']['Reserved.DataModel.ProductName'])
Ejemplo n.º 4
0
    def test_limited_retry_sender(self):
        mock_url_open = mock.Mock()

        with mock.patch.object(http_client_t, 'urlopen', mock_url_open):
            sender = _NoRetrySender()
            sender.send(self.sample_data[0])

        mock_url_open.assert_called_once()
        args, kwargs = mock_url_open.call_args

        self.assertEqual(10, kwargs['timeout'])

        data = json.loads(args[0].data.decode('utf-8'))[0]
        self.assertEqual('Microsoft.ApplicationInsights.Event', data['name'])
        self.assertEqual(
            'UserTask', data['data']['baseData']['properties']
            ['Reserved.DataModel.EntityType'])
        self.assertEqual(
            'azurecli', data['data']['baseData']['properties']
            ['Reserved.DataModel.ProductName'])