diff options
author | toli <toli@tocker.local> | 2015-07-23 17:06:41 -0700 |
---|---|---|
committer | toli <toli@tocker.local> | 2015-07-24 13:03:47 -0700 |
commit | 1f857351391f1d50dd57b404cec313e61cf312f3 (patch) | |
tree | 6d71a3ef00bb6c3226408263704b4d9a7c88e1dc /test/test_producer.py | |
parent | 4955582be1443b75c23f700268b7abbef0fde0ad (diff) | |
download | kafka-python-1f857351391f1d50dd57b404cec313e61cf312f3.tar.gz |
Fixing https://github.com/mumrah/kafka-python/issues/434
Reworked the if statement logic to only call stop() on not-stopped objects.
added tests
Diffstat (limited to 'test/test_producer.py')
-rw-r--r-- | test/test_producer.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/test_producer.py b/test/test_producer.py index 27272f6..087e3ae 100644 --- a/test/test_producer.py +++ b/test/test_producer.py @@ -91,6 +91,20 @@ class TestKafkaProducer(unittest.TestCase): with self.assertRaises(FailedPayloadsError): producer.send_messages('foobar', b'test message') + def test_cleanup_stop_is_called_on_not_stopped_object(self): + producer = Producer(MagicMock(), async=True) + producer.stopped = True + with patch('kafka.producer.base.Producer.stop') as base_stop: + producer._cleanup_func(producer) + self.assertEqual(base_stop.call_count, 0) + + def test_cleanup_stop_is_not_called_on_stopped_object(self): + producer = Producer(MagicMock(), async=True) + producer.stopped = False + with patch('kafka.producer.base.Producer.stop') as base_stop: + producer._cleanup_func(producer) + self.assertEqual(base_stop.call_count, 1) + class TestKafkaProducerSendUpstream(unittest.TestCase): |