~saviq/charm-helpers/confg-patterns

« back to all changes in this revision

Viewing changes to tests/contrib/openstack/test_os_templating.py

  • Committer: Michał Sawicz
  • Date: 2015-06-01 16:55:45 UTC
  • Revision ID: michal.sawicz@canonical.com-20150601165545-fxz5mokz3dxw6dlx
Refactor test to disallow additional calls

Show diffs side-by-side

added added

removed removed

Lines of Context:
211
211
        self.renderer.register_pattern('/tmp/foo_{}', [self.pattern_context])
212
212
        _glob.return_value = []
213
213
        
 
214
        ex_calls = [
 
215
            call('/tmp/foo_1', 'wb'),
 
216
            call('/tmp/foo_2', 'wb')
 
217
        ]
 
218
        
214
219
        with patch.object(self.renderer, '_get_template') as _get_t:
215
220
            fake_tmpl = MockTemplate()
216
221
            _get_t.return_value = fake_tmpl
217
222
            self.renderer.write('/tmp/foo_{}')
218
 
            _open.assert_has_calls([
219
 
                call('/tmp/foo_1', 'wb'),
220
 
                call('/tmp/foo_2', 'wb')
221
 
            ], any_order=True)
 
223
            self.assertEquals(sorted(ex_calls), sorted(_open.call_args_list))
222
224
 
223
225
    @patch(builtin_open)
224
226
    @patch('os.unlink')