Пример #1
0
def fetch(opts):
    """
    Create a local mirror of one or more resources.
    """
    resources = _load(opts.resources, opts.output_dir)
    if opts.all:
        opts.resource_names = ALL
    reporthook = None if opts.quiet else lambda name: print('Fetching {}...'.format(name))
    if opts.verbose:
        backend.VERBOSE = True
    _fetch(resources, opts.resource_names, opts.mirror_url, opts.force, reporthook)
    return verify(opts)
Пример #2
0
 def test_fetch_reporthook(self, minvalid):
     reporthook = mock.Mock()
     minvalid.return_value = set(['invalid', 'opt-invalid'])
     jujuresources._fetch(self.resources, jujuresources.ALL, 'mirror', reporthook=reporthook)
     self.resources['invalid'].fetch.assert_called_once_with('mirror')
     assert not self.resources['valid'].fetch.called
     self.resources['opt-invalid'].fetch.assert_called_once_with('mirror')
     reporthook.assert_has_calls([
         mock.call('invalid'),
         mock.call('opt-invalid'),
     ], any_order=True)
     self.assertNotIn(mock.call('valid'), reporthook.call_args_list)
Пример #3
0
def fetch(opts):
    """
    Create a local mirror of one or more resources.
    """
    resources = _load(opts.resources, opts.output_dir)
    if opts.all:
        opts.resource_names = ALL
    reporthook = None if opts.quiet else lambda name: print('Fetching {}...'.
                                                            format(name))
    if opts.verbose:
        backend.VERBOSE = True
    _fetch(resources, opts.resource_names, opts.mirror_url, opts.force,
           reporthook)
    return verify(opts)
Пример #4
0
 def test_fetch_reporthook(self, minvalid):
     reporthook = mock.Mock()
     minvalid.return_value = set(['invalid', 'opt-invalid'])
     jujuresources._fetch(self.resources,
                          jujuresources.ALL,
                          'mirror',
                          reporthook=reporthook)
     self.resources['invalid'].fetch.assert_called_once_with('mirror')
     assert not self.resources['valid'].fetch.called
     self.resources['opt-invalid'].fetch.assert_called_once_with('mirror')
     reporthook.assert_has_calls([
         mock.call('invalid'),
         mock.call('opt-invalid'),
     ],
                                 any_order=True)
     self.assertNotIn(mock.call('valid'), reporthook.call_args_list)
Пример #5
0
 def test_fetch(self, minvalid):
     minvalid.return_value = set(['invalid'])
     jujuresources._fetch(self.resources, None, 'mirror')
     self.resources['invalid'].fetch.assert_called_once_with('mirror')
     assert not self.resources['valid'].fetch.called
     assert not self.resources['opt-invalid'].fetch.called
Пример #6
0
 def test_fetch_force(self, minvalid):
     minvalid.return_value = set(['invalid'])
     jujuresources._fetch(self.resources, [], None, force=True)
     self.resources['invalid'].fetch.assert_called_once_with(None)
     self.resources['valid'].fetch.assert_called_once_with(None)
     assert not self.resources['opt-invalid'].fetch.called
Пример #7
0
 def test_fetch_force(self, minvalid):
     minvalid.return_value = set(['invalid'])
     jujuresources._fetch(self.resources, [], None, force=True)
     self.resources['invalid'].fetch.assert_called_once_with(None)
     self.resources['valid'].fetch.assert_called_once_with(None)
     assert not self.resources['opt-invalid'].fetch.called
Пример #8
0
 def test_fetch(self, minvalid):
     minvalid.return_value = set(['invalid'])
     jujuresources._fetch(self.resources, None, 'mirror')
     self.resources['invalid'].fetch.assert_called_once_with('mirror')
     assert not self.resources['valid'].fetch.called
     assert not self.resources['opt-invalid'].fetch.called