コード例 #1
0
    def test_update_snapshot(self):
        # Setup Expected Response
        name = 'name3373707'
        topic = 'topic110546223'
        expected_response = {'name': name, 'topic': topic}
        expected_response = pubsub_pb2.Snapshot(**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
        seconds = 123456
        expire_time = {'seconds': seconds}
        snapshot = {'expire_time': expire_time}
        paths_element = 'expire_time'
        paths = [paths_element]
        update_mask = {'paths': paths}

        response = client.update_snapshot(snapshot, update_mask)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = pubsub_pb2.UpdateSnapshotRequest(
            snapshot=snapshot, update_mask=update_mask)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
コード例 #2
0
    def test_update_snapshot(self):
        # Setup Expected Response
        name = 'name3373707'
        topic = 'topic110546223'
        expected_response = {'name': name, 'topic': topic}
        expected_response = pubsub_pb2.Snapshot(**expected_response)

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

        # Setup Request
        snapshot = {}
        update_mask = {}

        response = client.update_snapshot(snapshot, update_mask)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = pubsub_pb2.UpdateSnapshotRequest(
            snapshot=snapshot, update_mask=update_mask)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request