@@ -81,6 +81,30 @@ def unknown_topic_partition(request):
81
81
with self .assertRaises (UnknownTopicOrPartitionError ):
82
82
consumer .get_messages (20 )
83
83
84
+ def test_simple_consumer_commit_does_not_raise (self ):
85
+ client = MagicMock ()
86
+ client .get_partition_ids_for_topic .return_value = [0 , 1 ]
87
+
88
+ def mock_offset_fetch_request (group , payloads , ** kwargs ):
89
+ return [OffsetFetchResponse (p .topic , p .partition , 0 , b'' , 0 ) for p in payloads ]
90
+
91
+ client .send_offset_fetch_request .side_effect = mock_offset_fetch_request
92
+
93
+ def mock_offset_commit_request (group , payloads , ** kwargs ):
94
+ raise FailedPayloadsError (payloads [0 ])
95
+
96
+ client .send_offset_commit_request .side_effect = mock_offset_commit_request
97
+
98
+ consumer = SimpleConsumer (client , group = 'foobar' ,
99
+ topic = 'topic' , partitions = [0 , 1 ],
100
+ auto_commit = False )
101
+
102
+ # Mock internal commit check
103
+ consumer .count_since_commit = 10
104
+
105
+ # This should not raise an exception
106
+ self .assertFalse (consumer .commit (partitions = [0 , 1 ]))
107
+
84
108
@staticmethod
85
109
def fail_requests_factory (error_factory ):
86
110
# Mock so that only the first request gets a valid response
0 commit comments