ansible-core/fix-galaxy-cli-unit-test-asserts.patch

36 lines
2.0 KiB
Diff
Raw Normal View History

From 43c5cbcaef34aeb0141b8ad24027496bf6ec2acd Mon Sep 17 00:00:00 2001
From: Matt Clay <matt@mystile.com>
Date: Wed, 12 Apr 2023 10:32:59 -0700
Subject: [PATCH] Fix galaxy CLI unit test assertions (#80504)
---
test/units/cli/test_galaxy.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/test/units/cli/test_galaxy.py b/test/units/cli/test_galaxy.py
index 8f7e891e7d091f..c21d75dcb9a5f1 100644
--- a/test/units/cli/test_galaxy.py
+++ b/test/units/cli/test_galaxy.py
@@ -168,7 +168,9 @@ def test_exit_without_ignore_without_flag(self):
with patch.object(ansible.utils.display.Display, "display", return_value=None) as mocked_display:
# testing that error expected is raised
self.assertRaises(AnsibleError, gc.run)
- self.assertTrue(mocked_display.called_once_with("- downloading role 'fake_role_name', owned by "))
+ assert mocked_display.call_count == 2
+ assert mocked_display.mock_calls[0].args[0] == "Starting galaxy role install process"
+ assert "fake_role_name was NOT installed successfully" in mocked_display.mock_calls[1].args[0]
def test_exit_without_ignore_with_flag(self):
''' tests that GalaxyCLI exits without the error specified if the --ignore-errors flag is used '''
@@ -176,7 +178,9 @@ def test_exit_without_ignore_with_flag(self):
gc = GalaxyCLI(args=["ansible-galaxy", "install", "--server=None", "fake_role_name", "--ignore-errors"])
with patch.object(ansible.utils.display.Display, "display", return_value=None) as mocked_display:
gc.run()
- self.assertTrue(mocked_display.called_once_with("- downloading role 'fake_role_name', owned by "))
+ assert mocked_display.call_count == 2
+ assert mocked_display.mock_calls[0].args[0] == "Starting galaxy role install process"
+ assert "fake_role_name was NOT installed successfully" in mocked_display.mock_calls[1].args[0]
def test_parse_no_action(self):
''' testing the options parser when no action is given '''