~oddbloke/cloud-init/fix-gce-az

« back to all changes in this revision

Viewing changes to tests/unittests/helpers.py

  • Committer: Daniel Watkins
  • Date: 2015-07-22 12:06:34 UTC
  • Revision ID: daniel.watkins@canonical.com-20150722120634-wsg8rwzcaanhc2pn
Make full data source available to code that handles mirror selection.

Show diffs side-by-side

added added

removed removed

Lines of Context:
248
248
 
249
249
    def patchOS(self, new_root):
250
250
        patch_funcs = {
251
 
            os.path: ['isfile', 'exists', 'islink', 'isdir'],
252
 
            os: ['listdir'],
 
251
            os.path: [('isfile', 1), ('exists', 1),
 
252
                      ('islink', 1), ('isdir', 1)],
 
253
            os: [('listdir', 1), ('mkdir', 1),
 
254
                 ('lstat', 1), ('symlink', 2)],
253
255
        }
254
256
        for (mod, funcs) in patch_funcs.items():
255
 
            for f in funcs:
 
257
            for f, nargs in funcs:
256
258
                func = getattr(mod, f)
257
 
                trap_func = retarget_many_wrapper(new_root, 1, func)
 
259
                trap_func = retarget_many_wrapper(new_root, nargs, func)
258
260
                self.patched_funcs.enter_context(
259
261
                    mock.patch.object(mod, f, trap_func))
260
262