44 KafkaException , TIMESTAMP_NOT_AVAILABLE ,
55 OFFSET_INVALID , libversion )
66import pytest
7- from .common import get_consumer
7+ from .common import TestConsumer
88
99
1010def test_basic_api ():
1111 """ Basic API tests, these wont really do anything since there is no
1212 broker configured. """
1313
1414 with pytest .raises (TypeError ) as ex :
15- kc = get_consumer ()
15+ kc = TestConsumer ()
1616 assert ex .match ('expected configuration dict' )
1717
1818 def dummy_commit_cb (err , partitions ):
1919 pass
2020
21- kc = get_consumer ({'group.id' : 'test' , 'socket.timeout.ms' : '100' ,
21+ kc = TestConsumer ({'group.id' : 'test' , 'socket.timeout.ms' : '100' ,
2222 'session.timeout.ms' : 1000 , # Avoid close() blocking too long
2323 'on_commit' : dummy_commit_cb })
2424
@@ -120,7 +120,7 @@ def dummy_assign_revoke(consumer, partitions):
120120def test_store_offsets ():
121121 """ Basic store_offsets() tests """
122122
123- c = get_consumer ({'group.id' : 'test' ,
123+ c = TestConsumer ({'group.id' : 'test' ,
124124 'enable.auto.commit' : True ,
125125 'enable.auto.offset.store' : False ,
126126 'socket.timeout.ms' : 50 ,
@@ -162,7 +162,7 @@ def commit_cb(cs, err, ps):
162162
163163 cs = CommitState ('test' , 2 )
164164
165- c = get_consumer ({'group.id' : 'x' ,
165+ c = TestConsumer ({'group.id' : 'x' ,
166166 'enable.auto.commit' : False , 'socket.timeout.ms' : 50 ,
167167 'session.timeout.ms' : 100 ,
168168 'on_commit' : lambda err , ps : commit_cb (cs , err , ps )})
@@ -197,7 +197,7 @@ def poll(self, somearg):
197197@pytest .mark .skipif (libversion ()[1 ] < 0x000b0000 ,
198198 reason = "requires librdkafka >=0.11.0" )
199199def test_offsets_for_times ():
200- c = get_consumer ({'group.id' : 'test' ,
200+ c = TestConsumer ({'group.id' : 'test' ,
201201 'enable.auto.commit' : True ,
202202 'enable.auto.offset.store' : False ,
203203 'socket.timeout.ms' : 50 ,
@@ -217,7 +217,7 @@ def test_offsets_for_times():
217217def test_multiple_close_does_not_throw_exception ():
218218 """ Calling Consumer.close() multiple times should not throw Runtime Exception
219219 """
220- c = get_consumer ({'group.id' : 'test' ,
220+ c = TestConsumer ({'group.id' : 'test' ,
221221 'enable.auto.commit' : True ,
222222 'enable.auto.offset.store' : False ,
223223 'socket.timeout.ms' : 50 ,
@@ -233,7 +233,7 @@ def test_multiple_close_does_not_throw_exception():
233233def test_any_method_after_close_throws_exception ():
234234 """ Calling any consumer method after close should throw a RuntimeError
235235 """
236- c = get_consumer ({'group.id' : 'test' ,
236+ c = TestConsumer ({'group.id' : 'test' ,
237237 'enable.auto.commit' : True ,
238238 'enable.auto.offset.store' : False ,
239239 'socket.timeout.ms' : 50 ,
@@ -297,7 +297,7 @@ def test_any_method_after_close_throws_exception():
297297def test_calling_store_offsets_after_close_throws_erro ():
298298 """ calling store_offset after close should throw RuntimeError """
299299
300- c = get_consumer ({'group.id' : 'test' ,
300+ c = TestConsumer ({'group.id' : 'test' ,
301301 'enable.auto.commit' : True ,
302302 'enable.auto.offset.store' : False ,
303303 'socket.timeout.ms' : 50 ,
@@ -320,5 +320,5 @@ def test_consumer_without_groupid():
320320 """ Consumer should raise exception if group.id is not set """
321321
322322 with pytest .raises (ValueError ) as ex :
323- get_consumer ({'bootstrap.servers' : "mybroker:9092" })
323+ TestConsumer ({'bootstrap.servers' : "mybroker:9092" })
324324 assert ex .match ('group.id must be set' )
0 commit comments