Skip to content

Commit

Permalink
adding publisher basic test
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielePalaia committed Dec 13, 2024
1 parent 25ad6c6 commit 9b2b601
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
3 changes: 1 addition & 2 deletions examples/getting_started/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from proton import Message

from rabbitmq_amqp_python_client import (
BindingSpecification,
Connection,
ExchangeSpecification,
Message,
QueueSpecification,
QueueType,
exchange_address,
Expand Down
3 changes: 3 additions & 0 deletions rabbitmq_amqp_python_client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from importlib import metadata

from proton import Message

from .address_helper import exchange_address
from .common import QueueType
from .connection import Connection
Expand Down Expand Up @@ -27,4 +29,5 @@
"QueueType",
"Publisher",
"exchange_address",
"Message",
]
32 changes: 32 additions & 0 deletions tests/test_publisher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from rabbitmq_amqp_python_client import (
Connection,
Message,
QueueSpecification,
QueueType,
)


def test_bind_exchange_to_queue() -> None:
connection = Connection("amqp://guest:guest@localhost:5672/")
connection.dial()

queue_name = "test-queue"
management = connection.management()

management.declare_queue(
QueueSpecification(name=queue_name, queue_type=QueueType.quorum, arguments={})
)

raised = False

try:
publisher = connection.publisher("/queues/" + queue_name)
publisher.publish(Message(body="test"))
except Exception:
raised = True

assert raised is False

publisher.close()
# Still not working
# management.delete_queue(queue_name)

0 comments on commit 9b2b601

Please sign in to comment.