Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit 893add6

Browse files
committed
Added non-ascii tests
1 parent 584c0a3 commit 893add6

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

tests/asynctests/test_send_async.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -- coding: utf-8 --
12
#-------------------------------------------------------------------------
23
# Copyright (c) Microsoft Corporation. All rights reserved.
34
# Licensed under the MIT License. See License.txt in the project root for
@@ -8,6 +9,7 @@
89
import asyncio
910
import pytest
1011
import time
12+
import json
1113

1214
from azure.eventhub import EventData, EventHubClientAsync
1315

@@ -123,6 +125,25 @@ async def test_send_partition_async(connection_str, receivers):
123125
assert len(partition_1) == 1
124126

125127

128+
@pytest.mark.asyncio
129+
async def test_send_non_ascii_async(connection_str, receivers):
130+
client = EventHubClientAsync.from_connection_string(connection_str, debug=False)
131+
sender = client.add_async_sender(partition="0")
132+
try:
133+
await client.run_async()
134+
await sender.send(EventData("é,è,à,ù,â,ê,î,ô,û"))
135+
await sender.send(EventData(json.dumps({"foo": "漢字"})))
136+
except:
137+
raise
138+
finally:
139+
await client.stop_async()
140+
141+
partition_0 = receivers[0].receive(timeout=2)
142+
assert len(partition_0) == 2
143+
assert partition_0[0].body_as_str() == "é,è,à,ù,â,ê,î,ô,û"
144+
assert partition_0[1].body_as_json() == {"foo": "漢字"}
145+
146+
126147
@pytest.mark.asyncio
127148
async def test_send_partition_batch_async(connection_str, receivers):
128149
def batched():

tests/test_send.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -- coding: utf-8 --
12
#-------------------------------------------------------------------------
23
# Copyright (c) Microsoft Corporation. All rights reserved.
34
# Licensed under the MIT License. See License.txt in the project root for
@@ -7,6 +8,7 @@
78
import os
89
import pytest
910
import time
11+
import json
1012

1113
from azure import eventhub
1214
from azure.eventhub import EventData, EventHubClient
@@ -142,6 +144,24 @@ def test_send_partition(connection_str, receivers):
142144
assert len(partition_1) == 1
143145

144146

147+
def test_send_non_ascii(connection_str, receivers):
148+
client = EventHubClient.from_connection_string(connection_str, debug=False)
149+
sender = client.add_sender(partition="0")
150+
try:
151+
client.run()
152+
sender.send(EventData(u"é,è,à,ù,â,ê,î,ô,û"))
153+
sender.send(EventData(json.dumps({"foo": u"漢字"})))
154+
except:
155+
raise
156+
finally:
157+
client.stop()
158+
159+
partition_0 = receivers[0].receive(timeout=2)
160+
assert len(partition_0) == 2
161+
assert partition_0[0].body_as_str() == u"é,è,à,ù,â,ê,î,ô,û"
162+
assert partition_0[1].body_as_json() == {"foo": u"漢字"}
163+
164+
145165
def test_send_partition_batch(connection_str, receivers):
146166
def batched():
147167
for i in range(10):

0 commit comments

Comments
 (0)