diff --git a/test/units/cli/test_galaxy.py b/test/units/cli/test_galaxy.py index 686010a1f1..6506a59850 100644 --- a/test/units/cli/test_galaxy.py +++ b/test/units/cli/test_galaxy.py @@ -112,6 +112,20 @@ class TestGalaxy(unittest.TestCase): if display_result.find('\n\tgalaxy_info:') == -1: self.fail('Expected galaxy_info to be indented once') + def test_run(self): + ''' verifies that the GalaxyCLI object's api is created and that execute() is called. ''' + gc = GalaxyCLI(args=["install"]) + with patch('sys.argv', ["-c", "-v", '--ignore-errors', 'imaginary_role']): + galaxy_parser = gc.parse() + with patch.object(ansible.cli.CLI, "execute", return_value=None) as mock_ex: + with patch.object(ansible.cli.CLI, "run", return_value=None) as mock_run: + gc.run() + + # testing + self.assertEqual(mock_run.call_count, 1) + self.assertTrue(isinstance(gc.api, ansible.galaxy.api.GalaxyAPI)) + self.assertEqual(mock_ex.call_count, 1) + def test_execute_remove(self): # installing role gc = GalaxyCLI(args=["install", "--offline", "-p", self.role_path, "-r", self.role_req])