def test_seek(self):
        # Setup Expected Response
        expected_response = {}
        expected_response = pubsub_pb2.SeekResponse(**expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        client = subscriber_client.SubscriberClient(channel=channel)

        # Setup Request
        subscription = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]')

        response = client.seek(subscription)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = pubsub_pb2.SeekRequest(subscription=subscription)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Ejemplo n.º 2
0
    def test_seek(self):
        # Setup Expected Response
        expected_response = {}
        expected_response = pubsub_pb2.SeekResponse(**expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        patch = mock.patch('google.api_core.grpc_helpers.create_channel')
        with patch as create_channel:
            create_channel.return_value = channel
            client = subscriber_client.SubscriberClient()

        # Setup Request
        subscription = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]')

        response = client.seek(subscription)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = pubsub_pb2.SeekRequest(subscription=subscription)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request