SHA256
1
0
forked from pool/salt
salt/fix-unit-tests-for-batch-async-after-refactor.patch

53 lines
2.0 KiB
Diff
Raw Normal View History

From e9f2af1256a52d58a7c8e6dd0122eb6d5cc47dd3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
<psuarezhernandez@suse.com>
Date: Wed, 4 Mar 2020 10:13:43 +0000
Subject: [PATCH] Fix unit tests for batch async after refactor
---
tests/unit/cli/test_batch_async.py | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/tests/unit/cli/test_batch_async.py b/tests/unit/cli/test_batch_async.py
index f1d36a81fb..e1ce60859b 100644
--- a/tests/unit/cli/test_batch_async.py
+++ b/tests/unit/cli/test_batch_async.py
@@ -126,9 +126,10 @@ class AsyncBatchTestCase(AsyncTestCase, TestCase):
self.batch.timedout_minions = {'bar'}
self.batch.event = MagicMock()
self.batch.metadata = {'mykey': 'myvalue'}
+ old_event = self.batch.event
self.batch.end_batch()
self.assertEqual(
- self.batch.event.fire_event.call_args[0],
+ old_event.fire_event.call_args[0],
(
{
'available_minions': set(['foo', 'bar']),
@@ -146,6 +147,21 @@ class AsyncBatchTestCase(AsyncTestCase, TestCase):
event = MagicMock()
batch.event = event
batch.__del__()
+ self.assertEqual(batch.local, None)
+ self.assertEqual(batch.event, None)
+ self.assertEqual(batch.ioloop, None)
+
+ def test_batch_close_safe(self):
+ batch = BatchAsync(MagicMock(), MagicMock(), MagicMock())
+ event = MagicMock()
+ batch.event = event
+ batch.patterns = { ('salt/job/1234/ret/*', 'find_job_return'), ('salt/job/4321/ret/*', 'find_job_return') }
+ batch.close_safe()
+ self.assertEqual(batch.local, None)
+ self.assertEqual(batch.event, None)
+ self.assertEqual(batch.ioloop, None)
+ self.assertEqual(
+ len(event.unsubscribe.mock_calls), 2)
self.assertEqual(
len(event.remove_event_handler.mock_calls), 1)
--
2.23.0