code: def test_pulsar_write_simple_messages():
      """Test writing simple messages to a Pulsar topic with PulsarWriter"""
  
      topic = "test-write-simple-messages"
      writer = tfio.experimental.streaming.PulsarWriter(
          service_url="pulsar://localhost:6650", topic=topic
      )
      # 1. Write 10 messages
      for i in range(10):
          writer.write("msg-" + str(i))
      writer.flush()
  
      # 2. Consume messages and verify
      dataset = tfio.experimental.streaming.PulsarIODataset(
          service_url="pulsar://localhost:6650",
          topic=topic,
          subscription="subscription-0",
          timeout=default_pulsar_timeout,
      )
      assert np.all(
          [k.numpy() for (k, _) in dataset]
          == [("msg-" + str(i)).encode() for i in range(10)]
      )
  
file_path: io/tests/test_pulsar.py
imports: import sys
  import numpy
  import tensorflow
  import tensorflow_io
  import pytest
label_desc: Use image node_id 5 for calling a global function with example usage: test_pulsar_write_simple_messages() without return types