Update to work with latest mock
The `called_once` attribute now raises an exception. Switch to `assert_called_once` method. Also replace `assertTrue(x.called)` with `x.assert_called()`. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
88327d5784
commit
51628a974d
@ -45,7 +45,7 @@ class TestImageBuildPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
client_args = {
|
client_args = {
|
||||||
"original_image_conf": original_image_conf,
|
"original_image_conf": original_image_conf,
|
||||||
"image_conf": {
|
"image_conf": {
|
||||||
@ -137,7 +137,7 @@ class TestImageBuildPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
server_args = {
|
server_args = {
|
||||||
"original_image_conf": original_image_conf,
|
"original_image_conf": original_image_conf,
|
||||||
"image_conf": {
|
"image_conf": {
|
||||||
@ -196,7 +196,7 @@ class TestImageBuildPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
server_args = {
|
server_args = {
|
||||||
"original_image_conf": original_image_conf,
|
"original_image_conf": original_image_conf,
|
||||||
"image_conf": {
|
"image_conf": {
|
||||||
@ -261,8 +261,8 @@ class TestImageBuildPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertFalse(phase.pool.add.called)
|
phase.pool.add.assert_not_called()
|
||||||
self.assertFalse(phase.pool.queue_put.called)
|
phase.pool.queue_put.assert_not_called()
|
||||||
|
|
||||||
@mock.patch("pungi.phases.image_build.ThreadPool")
|
@mock.patch("pungi.phases.image_build.ThreadPool")
|
||||||
def test_image_build_set_install_tree(self, ThreadPool):
|
def test_image_build_set_install_tree(self, ThreadPool):
|
||||||
@ -297,9 +297,9 @@ class TestImageBuildPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
|
|
||||||
self.assertTrue(phase.pool.queue_put.called_once)
|
phase.pool.queue_put.assert_called_once()
|
||||||
args, kwargs = phase.pool.queue_put.call_args
|
args, kwargs = phase.pool.queue_put.call_args
|
||||||
self.assertEqual(args[0][0], compose)
|
self.assertEqual(args[0][0], compose)
|
||||||
self.assertDictEqual(
|
self.assertDictEqual(
|
||||||
@ -364,9 +364,9 @@ class TestImageBuildPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
|
|
||||||
self.assertTrue(phase.pool.queue_put.called_once)
|
phase.pool.queue_put.assert_called_once()
|
||||||
args, kwargs = phase.pool.queue_put.call_args
|
args, kwargs = phase.pool.queue_put.call_args
|
||||||
self.assertEqual(args[0][0], compose)
|
self.assertEqual(args[0][0], compose)
|
||||||
self.assertDictEqual(
|
self.assertDictEqual(
|
||||||
@ -430,9 +430,9 @@ class TestImageBuildPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
|
|
||||||
self.assertTrue(phase.pool.queue_put.called_once)
|
phase.pool.queue_put.assert_called_once()
|
||||||
args, kwargs = phase.pool.queue_put.call_args
|
args, kwargs = phase.pool.queue_put.call_args
|
||||||
self.assertEqual(args[0][0], compose)
|
self.assertEqual(args[0][0], compose)
|
||||||
self.assertDictEqual(
|
self.assertDictEqual(
|
||||||
@ -501,9 +501,9 @@ class TestImageBuildPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
|
|
||||||
self.assertTrue(phase.pool.queue_put.called_once)
|
phase.pool.queue_put.assert_called_once()
|
||||||
args, kwargs = phase.pool.queue_put.call_args
|
args, kwargs = phase.pool.queue_put.call_args
|
||||||
self.assertEqual(args[0][0], compose)
|
self.assertEqual(args[0][0], compose)
|
||||||
self.assertDictEqual(
|
self.assertDictEqual(
|
||||||
@ -569,9 +569,9 @@ class TestImageBuildPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
|
|
||||||
self.assertTrue(phase.pool.queue_put.called_once)
|
phase.pool.queue_put.assert_called_once()
|
||||||
args, kwargs = phase.pool.queue_put.call_args
|
args, kwargs = phase.pool.queue_put.call_args
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[0][1].get("image_conf", {}).get("image-build", {}).get("release"),
|
args[0][1].get("image_conf", {}).get("image-build", {}).get("release"),
|
||||||
@ -612,9 +612,9 @@ class TestImageBuildPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
|
|
||||||
self.assertTrue(phase.pool.queue_put.called_once)
|
phase.pool.queue_put.assert_called_once()
|
||||||
args, kwargs = phase.pool.queue_put.call_args
|
args, kwargs = phase.pool.queue_put.call_args
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[0][1].get("image_conf", {}).get("image-build", {}).get("release"),
|
args[0][1].get("image_conf", {}).get("image-build", {}).get("release"),
|
||||||
@ -655,9 +655,9 @@ class TestImageBuildPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
|
|
||||||
self.assertTrue(phase.pool.queue_put.called_once)
|
phase.pool.queue_put.assert_called_once()
|
||||||
args, kwargs = phase.pool.queue_put.call_args
|
args, kwargs = phase.pool.queue_put.call_args
|
||||||
self.assertTrue(args[0][1].get("scratch"))
|
self.assertTrue(args[0][1].get("scratch"))
|
||||||
|
|
||||||
@ -692,7 +692,7 @@ class TestImageBuildPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
server_args = {
|
server_args = {
|
||||||
"original_image_conf": original_image_conf,
|
"original_image_conf": original_image_conf,
|
||||||
"image_conf": {
|
"image_conf": {
|
||||||
@ -755,7 +755,7 @@ class TestImageBuildPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
server_args = {
|
server_args = {
|
||||||
"original_image_conf": original_image_conf,
|
"original_image_conf": original_image_conf,
|
||||||
"image_conf": {
|
"image_conf": {
|
||||||
|
@ -43,7 +43,7 @@ class TestLiveImagesPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
six.assertCountEqual(
|
six.assertCountEqual(
|
||||||
self,
|
self,
|
||||||
@ -124,7 +124,7 @@ class TestLiveImagesPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
six.assertCountEqual(
|
six.assertCountEqual(
|
||||||
self,
|
self,
|
||||||
@ -192,7 +192,7 @@ class TestLiveImagesPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
six.assertCountEqual(
|
six.assertCountEqual(
|
||||||
self,
|
self,
|
||||||
@ -265,7 +265,7 @@ class TestLiveImagesPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
six.assertCountEqual(
|
six.assertCountEqual(
|
||||||
self,
|
self,
|
||||||
@ -363,7 +363,7 @@ class TestLiveImagesPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
six.assertCountEqual(
|
six.assertCountEqual(
|
||||||
self,
|
self,
|
||||||
@ -433,7 +433,7 @@ class TestLiveImagesPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
six.assertCountEqual(
|
six.assertCountEqual(
|
||||||
self,
|
self,
|
||||||
@ -503,7 +503,7 @@ class TestLiveImagesPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
six.assertCountEqual(
|
six.assertCountEqual(
|
||||||
self,
|
self,
|
||||||
@ -571,7 +571,7 @@ class TestLiveImagesPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
# assert at least one thread was started
|
# assert at least one thread was started
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
six.assertCountEqual(
|
six.assertCountEqual(
|
||||||
self,
|
self,
|
||||||
|
@ -36,7 +36,7 @@ class TestLiveMediaPhase(PungiTestCase):
|
|||||||
phase = LiveMediaPhase(compose)
|
phase = LiveMediaPhase(compose)
|
||||||
|
|
||||||
phase.run()
|
phase.run()
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
phase.pool.queue_put.call_args_list,
|
phase.pool.queue_put.call_args_list,
|
||||||
[
|
[
|
||||||
@ -93,7 +93,7 @@ class TestLiveMediaPhase(PungiTestCase):
|
|||||||
phase = LiveMediaPhase(compose)
|
phase = LiveMediaPhase(compose)
|
||||||
|
|
||||||
phase.run()
|
phase.run()
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
phase.pool.queue_put.call_args_list,
|
phase.pool.queue_put.call_args_list,
|
||||||
[
|
[
|
||||||
@ -156,7 +156,7 @@ class TestLiveMediaPhase(PungiTestCase):
|
|||||||
phase = LiveMediaPhase(compose)
|
phase = LiveMediaPhase(compose)
|
||||||
|
|
||||||
phase.run()
|
phase.run()
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
phase.pool.queue_put.call_args_list,
|
phase.pool.queue_put.call_args_list,
|
||||||
[
|
[
|
||||||
@ -267,7 +267,7 @@ class TestLiveMediaPhase(PungiTestCase):
|
|||||||
phase = LiveMediaPhase(compose)
|
phase = LiveMediaPhase(compose)
|
||||||
|
|
||||||
phase.run()
|
phase.run()
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
phase.pool.queue_put.call_args_list,
|
phase.pool.queue_put.call_args_list,
|
||||||
[
|
[
|
||||||
@ -444,7 +444,7 @@ class TestLiveMediaPhase(PungiTestCase):
|
|||||||
phase = LiveMediaPhase(compose)
|
phase = LiveMediaPhase(compose)
|
||||||
|
|
||||||
phase.run()
|
phase.run()
|
||||||
self.assertTrue(phase.pool.add.called)
|
phase.pool.add.assert_called()
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
phase.pool.queue_put.call_args_list,
|
phase.pool.queue_put.call_args_list,
|
||||||
|
@ -133,7 +133,7 @@ class TestNotifier(unittest.TestCase):
|
|||||||
def test_does_not_run_without_config(self, run, makedirs):
|
def test_does_not_run_without_config(self, run, makedirs):
|
||||||
n = PungiNotifier(None)
|
n = PungiNotifier(None)
|
||||||
n.send("cmd", foo="bar", baz="quux")
|
n.send("cmd", foo="bar", baz="quux")
|
||||||
self.assertFalse(run.called)
|
run.assert_not_called()
|
||||||
|
|
||||||
@mock.patch("pungi.util.translate_path")
|
@mock.patch("pungi.util.translate_path")
|
||||||
@mock.patch("kobo.shortcuts.run")
|
@mock.patch("kobo.shortcuts.run")
|
||||||
@ -146,4 +146,4 @@ class TestNotifier(unittest.TestCase):
|
|||||||
n.send("cmd", **self.data)
|
n.send("cmd", **self.data)
|
||||||
|
|
||||||
self.assertEqual(run.call_args_list, [self._call("run-notify", "cmd")])
|
self.assertEqual(run.call_args_list, [self._call("run-notify", "cmd")])
|
||||||
self.assertTrue(self.compose.log_warning.called)
|
self.compose.log_warning.assert_called()
|
||||||
|
Loading…
Reference in New Issue
Block a user