testing GalaxyCLI.run() does what is expected

This commit is contained in:
s-hertel 2016-07-13 14:58:39 -04:00 committed by Matt Clay
parent b688f11474
commit 28b4931e3d

View file

@ -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])