From 28b4931e3dc7a742b0cd9f6d4e8f1db56ed8f2ef Mon Sep 17 00:00:00 2001 From: s-hertel Date: Wed, 13 Jul 2016 14:58:39 -0400 Subject: [PATCH] testing GalaxyCLI.run() does what is expected --- test/units/cli/test_galaxy.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/units/cli/test_galaxy.py b/test/units/cli/test_galaxy.py index 686010a1f1a..6506a598507 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])