summaryrefslogtreecommitdiff
path: root/test/test_producer.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_producer.py')
-rw-r--r--test/test_producer.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/test_producer.py b/test/test_producer.py
index e681e43..3c026e8 100644
--- a/test/test_producer.py
+++ b/test/test_producer.py
@@ -111,6 +111,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):