Ejemplo n.º 1
0
    def test_get_subscription_exception(self):
        # Mock the API response
        channel = ChannelStub(responses=[CustomException()])
        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]")

        with pytest.raises(CustomException):
            client.get_subscription(subscription)
Ejemplo n.º 2
0
    def test_modify_ack_deadline_exception(self):
        # Mock the API response
        channel = ChannelStub(responses=[CustomException()])
        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]")
        ack_ids = []
        ack_deadline_seconds = 2135351438

        with pytest.raises(CustomException):
            client.modify_ack_deadline(subscription, ack_ids, ack_deadline_seconds)