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()
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()
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'])
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'])