Skip to content

Commit

Permalink
Coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
lhellebr committed Jun 21, 2023
1 parent 83e32cc commit a0f54c4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ def test_id_and_which(self):
(entities.Host, 'smart_class_parameters'),
(entities.Host, 'ansible_roles'),
(entities.Host, 'assign_ansible_roles'),
(entities.Host, 'play_roles'),
(entities.HostGroup, 'ansible_roles'),
(entities.HostGroup, 'assign_ansible_roles'),
(entities.HostGroup, 'clone'),
Expand Down Expand Up @@ -3163,6 +3164,22 @@ def test_disassociate(self):
self.assertEqual(len(put.call_args[1]), 0) # post called with no keyword argument
self.assertEqual(put.call_args[0][0], 'foo/api/v2/hosts/42/disassociate')

def test_play_ansible_roles(self):
"""Play Ansible roles"""
cfg = config.ServerConfig(url='foo')
host = entities.Host(cfg, id=42)
exp_ret = mock.MagicMock()
exp_ret.status = ACCEPTED
exp_ret.content = {'bar': 'baz', 'task_id': 43}
with mock.patch.object(client, 'post', return_value=exp_ret) as post:
res = host.play_ansible_roles()
self.assertEqual(post.call_count, 1)
self.assertEqual(len(post.call_args), 2)
self.assertEqual(len(post.call_args[0]), 1) # post called with 1 positional argument
self.assertEqual(len(post.call_args[1]), 0) # post called with no keyword argument
self.assertEqual(post.call_args[0][0], 'foo/api/v2/hosts/42/play_roles')
self.assertEqual(res, 43)


class PuppetClassTestCase(TestCase):
"""Tests for :class:`nailgun.entities.PuppetClass`."""
Expand Down

0 comments on commit a0f54c4

Please sign in to comment.