Skip to content

Commit 5af7330

Browse files
authored
Merge pull request #69 from RongtongJin/ctypes_test
chore(tests): polish tests
2 parents 8bbac05 + 645768d commit 5af7330

3 files changed

Lines changed: 16 additions & 7 deletions

File tree

tests/conftest.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,23 @@
2222

2323
@pytest.fixture(scope='session')
2424
def producer():
25-
prod = Producer('testGroup', True)
25+
prod = Producer('producer_group')
2626
prod.set_namesrv_addr('127.0.0.1:9876')
2727
prod.start()
2828
yield prod
2929
prod.shutdown()
3030

31+
@pytest.fixture(scope='session')
32+
def orderly_producer():
33+
prod = Producer('orderly_producer_group', True)
34+
prod.set_namesrv_addr('127.0.0.1:9876')
35+
prod.start()
36+
yield prod
37+
prod.shutdown()
3138

3239
@pytest.fixture(scope='function')
3340
def push_consumer():
34-
consumer = PushConsumer('testGroup')
41+
consumer = PushConsumer('push_consumer_group')
3542
consumer.set_namesrv_addr('127.0.0.1:9876')
3643
yield consumer
3744
consumer.shutdown()

tests/test_consumer.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import pytest
2323

24-
from rocketmq.client import Message, SendStatus, ConsumeStatus
24+
from rocketmq.client import Message, SendStatus, ConsumeStatus, PushConsumer
2525
from rocketmq.exceptions import PushConsumerStartFailed
2626
from rocketmq.consts import MessageProperty
2727

@@ -35,9 +35,11 @@ def _send_test_msg(producer):
3535
assert ret.status == SendStatus.OK
3636

3737

38-
def test_push_consumer_no_subscription_start_fail(push_consumer):
38+
def test_push_consumer_no_subscription_start_fail():
39+
consumer = PushConsumer('testGroup')
40+
consumer.set_namesrv_addr("127.0.0.1:9876")
3941
with pytest.raises(PushConsumerStartFailed):
40-
push_consumer.start()
42+
consumer.start()
4143

4244

4345
def test_push_consumer(producer, push_consumer):

tests/test_producer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ def test_producer_send_oneway(producer):
4242
producer.send_oneway(msg)
4343

4444

45-
def test_producer_send_orderly_with_sharding_key(producer):
45+
def test_producer_send_orderly_with_sharding_key(orderly_producer):
4646
msg = Message('test')
4747
msg.set_keys('sharding_message')
4848
msg.set_tags('sharding')
4949
msg.set_body('sharding message')
50-
ret = producer.send_orderly_with_sharding_key(msg, 'order1')
50+
ret = orderly_producer.send_orderly_with_sharding_key(msg, 'order1')
5151
assert ret.status == SendStatus.OK
5252

5353

0 commit comments

Comments
 (0)