Пример #1
0
    def test_intercept_unary_unary(self):
        interceptor = Client.MetadataInterceptor(self.mock_developer_token,
                                                 self.mock_login_customer_id)

        mock_continuation = mock.Mock(return_value=None)
        mock_client_call_details = mock.Mock()
        mock_client_call_details.method = 'test/method'
        mock_client_call_details.timeout = 5
        mock_client_call_details.metadata = [('apples', 'oranges')]
        mock_request = mock.Mock()

        with mock.patch.object(
                interceptor,
                '_update_client_call_details_metadata',
                wraps=interceptor._update_client_call_details_metadata
        ) as mock_updater:
            interceptor.intercept_unary_unary(mock_continuation,
                                              mock_client_call_details,
                                              mock_request)

            mock_updater.assert_called_once_with(mock_client_call_details, [
                mock_client_call_details.metadata[0],
                interceptor.developer_token_meta,
                interceptor.login_customer_id_meta
            ])

            mock_continuation.assert_called_once()
Пример #2
0
    def test_init_no_login_customer_id(self):
        interceptor = Client.MetadataInterceptor(self.mock_developer_token,
                                                 None)

        self.assertEqual(interceptor.developer_token_meta,
                         ('developer-token', self.mock_developer_token))

        self.assertEqual(interceptor.login_customer_id_meta, None)
Пример #3
0
    def test_update_client_call_details_metadata(self):
        interceptor = Client.MetadataInterceptor(self.mock_developer_token,
                                                 self.mock_login_customer_id)

        mock_metadata = list([('test-key', 'test-value')])
        mock_client_call_details = mock.Mock()

        client_call_details = interceptor._update_client_call_details_metadata(
            mock_client_call_details, mock_metadata)

        self.assertEqual(client_call_details.metadata, mock_metadata)