Skip to content

Commit 1d28d64

Browse files
author
DanielePalaia
committed
adding publisher basic test
1 parent e0be74f commit 1d28d64

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

examples/getting_started/main.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
from proton import Message
2-
31
from rabbitmq_amqp_python_client import (
42
BindingSpecification,
53
Connection,
64
ExchangeSpecification,
5+
Message,
76
QueueSpecification,
87
QueueType,
98
exchange_address,

rabbitmq_amqp_python_client/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from importlib import metadata
22

3+
from proton import Message
4+
35
from .address_helper import exchange_address
46
from .common import QueueType
57
from .connection import Connection
@@ -27,4 +29,5 @@
2729
"QueueType",
2830
"Publisher",
2931
"exchange_address",
32+
"Message",
3033
]

tests/test_publisher.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from rabbitmq_amqp_python_client import (
2+
Connection,
3+
Message,
4+
QueueSpecification,
5+
QueueType,
6+
)
7+
8+
9+
def test_bind_exchange_to_queue() -> None:
10+
connection = Connection("amqp://guest:guest@localhost:5672/")
11+
connection.dial()
12+
13+
queue_name = "test-queue"
14+
management = connection.management()
15+
16+
management.declare_queue(
17+
QueueSpecification(name=queue_name, queue_type=QueueType.quorum, arguments={})
18+
)
19+
20+
raised = False
21+
22+
try:
23+
publisher = connection.publisher("/queues/" + queue_name)
24+
publisher.publish(Message(body="test"))
25+
except Exception:
26+
raised = True
27+
28+
assert raised is False
29+
30+
publisher.close()
31+
# Still not working
32+
# management.delete_queue(queue_name)

0 commit comments

Comments
 (0)