~michael.nelson/charm-helpers/ansible-detect-hooks

« back to all changes in this revision

Viewing changes to tests/contrib/ansible/test_ansible.py

  • Committer: Michael Nelson
  • Date: 2014-04-16 10:15:18 UTC
  • Revision ID: michael.nelson@canonical.com-20140416101518-77vu1rnft310ry8x
Hook-up with get_tags_for_playbook.

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
        patcher.start()
127
127
        self.addCleanup(patcher.stop)
128
128
 
 
129
        patcher = mock.patch(
 
130
            'charmhelpers.contrib.ansible.get_tags_for_playbook')
 
131
        self.mock_get_tags_for_playbook = patcher.start()
 
132
        self.addCleanup(patcher.stop)
 
133
        self.mock_get_tags_for_playbook.return_value = []
 
134
 
129
135
    def test_calls_ansible_playbook(self):
130
136
        charmhelpers.contrib.ansible.apply_playbook(
131
137
            'playbooks/dependencies.yaml')
183
189
            'ansible-playbook', '-c', 'local', 'playbooks/complete-state.yaml',
184
190
            '--tags', 'install,somethingelse'])
185
191
 
186
 
    def patch_available_tags(self, tags):
187
 
        patcher = mock.patch.object(charmhelpers.contrib.ansible,
188
 
                                    'available_tags', tags)
189
 
        patcher.start()
190
 
        self.addCleanup(patcher.stop)
191
 
 
192
192
    def test_hooks_executes_playbook_with_tag(self):
 
193
        self.mock_get_tags_for_playbook.return_value = ['foo']
193
194
        hooks = charmhelpers.contrib.ansible.AnsibleHooks('my/playbook.yaml')
194
195
        foo = mock.MagicMock()
195
196
        hooks.register('foo', foo)
196
 
        self.patch_available_tags(['foo'])
197
197
 
198
198
        hooks.execute(['foo'])
199
199