Skip to content

Commit 9bae5ca

Browse files
committed
converter
Signed-off-by: Gabriele Santomaggio <[email protected]>
1 parent 847c08c commit 9bae5ca

File tree

5 files changed

+40
-34
lines changed

5 files changed

+40
-34
lines changed

.ci/ubuntu/gha-setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set -o xtrace
77
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
88
readonly script_dir
99
echo "[INFO] script_dir: '$script_dir'"
10-
readonly rabbitmq_image=rabbitmq:4.1.0-beta.4-management-alpine
10+
readonly rabbitmq_image=rabbitmq:4.1.0-management
1111

1212

1313
readonly docker_name_prefix='rabbitmq-amqp-python-client'

examples/getting_started/getting_started.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111
ExchangeToQueueBindingSpecification,
1212
Message,
1313
OutcomeState,
14-
QuorumQueueSpecification,
15-
)
16-
from rabbitmq_amqp_python_client.utils import (
17-
bytes_to_string,
18-
string_to_bytes,
14+
QuorumQueueSpecification, Converter,
1915
)
2016

2117
MESSAGES_TO_PUBLISH = 100
@@ -28,7 +24,7 @@ def __init__(self):
2824
self._count = 0
2925

3026
def on_amqp_message(self, event: Event):
31-
print("received message: {} ".format(bytes_to_string(event.message.body)))
27+
print("received message: {} ".format(Converter.bytes_to_string(event.message.body)))
3228

3329
# accepting
3430
self.delivery_context.accept(event)
@@ -47,13 +43,11 @@ def on_amqp_message(self, event: Event):
4743
# in case of rejection with annotations added
4844
# self.delivery_context.discard_with_annotations(event)
4945

50-
print("count " + str(self._count))
51-
5246
self._count = self._count + 1
47+
print("count " + str(self._count))
5348

5449
if self._count == MESSAGES_TO_PUBLISH:
55-
print("closing receiver")
56-
# if you want you can add cleanup operations here
50+
print("received all messages")
5751

5852
def on_connection_closed(self, event: Event):
5953
# if you want you can add cleanup operations here
@@ -125,9 +119,8 @@ def main() -> None:
125119

126120
# publish 10 messages
127121
for i in range(MESSAGES_TO_PUBLISH):
128-
print("publishing")
129122
status = publisher.publish(
130-
Message(body=string_to_bytes("test message {} ".format(i)))
123+
Message(body=Converter.string_to_bytes("test message {} ".format(i)))
131124
)
132125
if status.remote_state == OutcomeState.ACCEPTED:
133126
print("message accepted")

rabbitmq_amqp_python_client/connection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ def dial(self) -> None:
180180
self._ssl_domain = SSLDomain(SSLDomain.MODE_CLIENT)
181181
assert self._ssl_domain
182182

183+
183184
if isinstance(self._conf_ssl_context, PosixSslConfigurationContext):
184185
ca_cert = self._conf_ssl_context.ca_cert
185186
elif isinstance(self._conf_ssl_context, WinSslConfigurationContext):

rabbitmq_amqp_python_client/qpid/proton/_message.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ def instructions(self) -> Optional[AnnotationDict]:
511511

512512
@instructions.setter
513513
def instructions(
514-
self, instructions: Optional[Dict[Union[str, int], "PythonAMQPData"]]
514+
self, instructions: Optional[Dict[Union[str, int], "PythonAMQPData"]]
515515
) -> None:
516516
if isinstance(instructions, dict):
517517
self.instruction_dict = AnnotationDict(instructions, raise_on_error=False)
@@ -534,7 +534,7 @@ def annotations(self) -> Optional[AnnotationDict]:
534534

535535
@annotations.setter
536536
def annotations(
537-
self, annotations: Optional[Dict[Union[str, int], "PythonAMQPData"]]
537+
self, annotations: Optional[Dict[Union[str, int], "PythonAMQPData"]]
538538
) -> None:
539539
if isinstance(annotations, dict):
540540
self.annotation_dict = AnnotationDict(annotations, raise_on_error=False)
@@ -601,7 +601,8 @@ def send(self, sender: "Sender", tag: Optional[str] = None) -> "Delivery":
601601
return dlv
602602

603603
@overload
604-
def recv(self, link: "Sender") -> None: ...
604+
def recv(self, link: "Sender") -> None:
605+
...
605606

606607
def recv(self, link: "Receiver") -> Optional["Delivery"]:
607608
"""
@@ -632,24 +633,24 @@ def recv(self, link: "Receiver") -> Optional["Delivery"]:
632633
def __repr__(self) -> str:
633634
props = []
634635
for attr in (
635-
"inferred",
636-
"address",
637-
"reply_to",
638-
"durable",
639-
"ttl",
640-
"priority",
641-
"first_acquirer",
642-
"delivery_count",
643-
"id",
644-
"correlation_id",
645-
"user_id",
646-
"group_id",
647-
"group_sequence",
648-
"reply_to_group_id",
649-
"instructions",
650-
"annotations",
651-
"properties",
652-
"body",
636+
"inferred",
637+
"address",
638+
"reply_to",
639+
"durable",
640+
"ttl",
641+
"priority",
642+
"first_acquirer",
643+
"delivery_count",
644+
"id",
645+
"correlation_id",
646+
"user_id",
647+
"group_id",
648+
"group_sequence",
649+
"reply_to_group_id",
650+
"instructions",
651+
"annotations",
652+
"properties",
653+
"body",
653654
):
654655
value = getattr(self, attr)
655656
if value:

tests/test_connection.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import time
22
from datetime import datetime, timedelta
3+
from pathlib import Path
34

45
from rabbitmq_amqp_python_client import (
56
ConnectionClosed,
@@ -37,7 +38,17 @@ def test_connection_ssl(ssl_context) -> None:
3738
environment = Environment(
3839
"amqps://guest:guest@localhost:5671/",
3940
ssl_context=ssl_context,
41+
4042
)
43+
path = Path(ssl_context.ca_cert)
44+
assert path.is_file() is True
45+
assert path.exists() is True
46+
47+
path = Path(ssl_context.client_cert.client_cert)
48+
assert path.is_file() is True
49+
50+
path = Path(ssl_context.client_cert.client_key)
51+
assert path.is_file() is True
4152

4253
connection = environment.connection()
4354
connection.dial()

0 commit comments

Comments
 (0)