def test_get_tenant_from_coordinator_throws_communication_error(self): http_request = MagicMock(side_effect=requests.RequestException) with patch.object(correlator, '_get_config_from_cache', self.get_config), \ patch('meniscus.correlation.correlator.http_request', http_request): with self.assertRaises(errors.CoordinatorCommunicationError): correlator._get_tenant_from_coordinator( self.tenant_id, self.message_token, self.src_msg)
def test_get_tenant_from_coordinator_throws_resource_not_found_error(self): response = MagicMock() response.status_code = httplib.BAD_REQUEST http_request = MagicMock(return_value=response) with patch.object(correlator, '_get_config_from_cache', self.get_config), \ patch('meniscus.correlation.correlator.http_request', http_request): with self.assertRaises(errors.CoordinatorCommunicationError): correlator._get_tenant_from_coordinator( self.tenant_id, self.invalid_message_token, self.src_msg)
def test_get_tenant_from_coordinator_throws_resource_not_found_error(self): response = MagicMock() response.status_code = httplib.BAD_REQUEST http_request = MagicMock(return_value=response) with patch.object(correlator, '_get_config_from_cache', self.get_config), \ patch('meniscus.correlation.correlator.http_request', http_request): with self.assertRaises(errors.CoordinatorCommunicationError): correlator._get_tenant_from_coordinator( self.tenant_id, self.invalid_message_token, self.src_msg)
def test_get_tenant_from_coordinator_throws_communication_error(self): http_request = MagicMock( side_effect=requests.RequestException) with patch.object(correlator, '_get_config_from_cache', self.get_config), \ patch('meniscus.correlation.correlator.http_request', http_request): with self.assertRaises(errors.CoordinatorCommunicationError): correlator._get_tenant_from_coordinator(self.tenant_id, self.message_token, self.src_msg)
def test_get_tenant_from_coordinator_calls_get_tenant(self): response = MagicMock() response.status_code = httplib.OK http_request = MagicMock(return_value=response) add_correlation_info_to_message_func = MagicMock() with patch.object(correlator, '_get_config_from_cache', self.get_config), \ patch('meniscus.correlation.correlator.http_request', http_request), \ patch('meniscus.correlation.correlator.tenant_util.' 'load_tenant_from_dict', self.tenant_found), \ patch('meniscus.correlation.correlator.' '_add_correlation_info_to_message', add_correlation_info_to_message_func): correlator._get_tenant_from_coordinator(self.tenant_id, self.message_token, self.src_msg) add_correlation_info_to_message_func.assert_called_once_with( self.tenant, self.src_msg)
def test_get_tenant_from_coordinator_calls_get_tenant(self): response = MagicMock() response.status_code = httplib.OK http_request = MagicMock(return_value=response) add_correlation_info_to_message_func = MagicMock() with patch.object(correlator, '_get_config_from_cache', self.get_config), \ patch('meniscus.correlation.correlator.http_request', http_request), \ patch('meniscus.correlation.correlator.tenant_util.' 'load_tenant_from_dict', self.tenant_found), \ patch('meniscus.correlation.correlator.' '_add_correlation_info_to_message', add_correlation_info_to_message_func): correlator._get_tenant_from_coordinator(self.tenant_id, self.message_token, self.src_msg) add_correlation_info_to_message_func.assert_called_once_with( self.tenant, self.src_msg)