def test_already_opened(self, lib): path = '/tmp/path-1' _lib = Mock() lib.return_value = _lib # test repo = Repository(path) repo.impl = Mock() repo.open() # validation self.assertFalse(_lib.OSTree.Repo.new.called)
def test_pull_local_all(self, lib): path = '/tmp/path-2' path_in = '/tmp/path-1' url = 'file://%s' % path_in refs = None mirror = 0xFF depth = 3 _lib = Mock() lib_repo = Mock() _lib.GLib.Variant.side_effect = Mock(side_effect=variant) _lib.OSTree.RepoPullFlags.MIRROR = mirror lib.return_value = _lib # test repo = Repository(path) repo.open = Mock() repo.impl = lib_repo repo.pull_local(path_in, refs, depth) # validation options = ('a{sv}', {'depth': ('i', depth), 'flags': ('i', mirror)}) lib.assert_called_with() repo.open.assert_called_once_with() lib_repo.pull_with_options.assert_called_once_with( url, options, None, None)
def test_pull_all(self, lib): path = '/tmp/path-1' remote_id = 'remote-1' depth = 3 refs = None mirror = 0xFF listener = Mock() _lib = Mock() lib_repo = Mock() progress = Mock() _lib.GLib.Variant.side_effect = Mock(side_effect=variant) _lib.OSTree.AsyncProgress.new.return_value = progress _lib.OSTree.RepoPullFlags.MIRROR = mirror lib.return_value = _lib # test repo = Repository(path) repo.open = Mock() repo.impl = lib_repo repo.pull(remote_id, refs, listener, depth) # validation options = ('a{sv}', {'depth': ('i', depth), 'flags': ('i', mirror)}) lib.assert_called_with() repo.open.assert_called_once_with() progress.connect.assert_called_once_with('changed', ANY) lib_repo.pull_with_options.assert_called_once_with( remote_id, options, progress, None) progress.finish.assert_called_once_with()
def test_pull_local(self, lib): path = '/tmp/path-2' path_in = '/tmp/path-1' url = 'file://%s' % path_in refs = ['branch-1'] mirror = 'MIRROR' _lib = Mock() lib_repo = Mock() _lib.GLib.Variant.side_effect = Mock(side_effect=variant) _lib.OSTree.RepoPullFlags.MIRROR = mirror lib.return_value = _lib # test repo = Repository(path) repo.open = Mock() repo.impl = lib_repo repo.pull_local(path_in, refs) # validation options = ('a{sv}', { 'refs': ('as', ('branch-1', )), 'flags': ('u', 'MIRROR') }) lib.assert_called_with() repo.open.assert_called_once_with() lib_repo.pull_with_options.assert_called_once_with( url, options, None, None)
def test_pull(self, lib): path = '/tmp/path-1' remote_id = 'remote-1' refs = ['branch-1'] mirror = 'MIRROR' listener = Mock() _lib = Mock() lib_repo = Mock() progress = Mock() _lib.OSTree.AsyncProgress.new.return_value = progress _lib.OSTree.RepoPullFlags.MIRROR = mirror lib.return_value = _lib # test repo = Repository(path) repo.open = Mock() repo.impl = lib_repo repo.pull(remote_id, refs, listener) # validation lib.assert_called_with() repo.open.assert_called_once_with() progress.connect.assert_called_once_with('changed', ANY) lib_repo.pull.assert_called_once_with(remote_id, refs, mirror, progress, None) progress.finish.assert_called_once_with()
def test_pull_local_all(self, lib): path = '/tmp/path-2' path_in = '/tmp/path-1' url = 'file://%s' % path_in refs = None mirror = 0xFF depth = 3 _lib = Mock() lib_repo = Mock() _lib.GLib.Variant.side_effect = Mock(side_effect=variant) _lib.OSTree.RepoPullFlags.MIRROR = mirror lib.return_value = _lib # test repo = Repository(path) repo.open = Mock() repo.impl = lib_repo repo.pull_local(path_in, refs, depth) # validation options = ( 'a{sv}', { 'depth': ('i', depth), 'flags': ('i', mirror) }) lib.assert_called_with() repo.open.assert_called_once_with() lib_repo.pull_with_options.assert_called_once_with(url, options, None, None)
def test_pull_all(self, lib): path = '/tmp/path-1' remote_id = 'remote-1' depth = 3 refs = None mirror = 0xFF listener = Mock() _lib = Mock() lib_repo = Mock() progress = Mock() _lib.GLib.Variant.side_effect = Mock(side_effect=variant) _lib.OSTree.AsyncProgress.new.return_value = progress _lib.OSTree.RepoPullFlags.MIRROR = mirror lib.return_value = _lib # test repo = Repository(path) repo.open = Mock() repo.impl = lib_repo repo.pull(remote_id, refs, listener, depth) # validation options = ( 'a{sv}', { 'depth': ('i', depth), 'flags': ('i', mirror) }) lib.assert_called_with() repo.open.assert_called_once_with() progress.connect.assert_called_once_with('changed', ANY) lib_repo.pull_with_options.assert_called_once_with(remote_id, options, progress, None) progress.finish.assert_called_once_with()
def test_pull_local(self, lib): path = '/tmp/path-2' path_in = '/tmp/path-1' url = 'file://%s' % path_in refs = ['branch-1'] mirror = 'MIRROR' _lib = Mock() lib_repo = Mock() _lib.GLib.Variant.side_effect = Mock(side_effect=variant) _lib.OSTree.RepoPullFlags.MIRROR = mirror lib.return_value = _lib # test repo = Repository(path) repo.open = Mock() repo.impl = lib_repo repo.pull_local(path_in, refs) # validation options = ( 'a{sv}', { 'refs': ('as', ('branch-1',)), 'flags': ('u', 'MIRROR') }) lib.assert_called_with() repo.open.assert_called_once_with() lib_repo.pull_with_options.assert_called_once_with(url, options, None, None)
def test_open(self, lib): fp = Mock() path = '/tmp/path-1' lib_repo = Mock() _lib = Mock() _lib.Gio.File.new_for_path.return_value = fp _lib.OSTree.Repo.new.return_value = lib_repo lib.return_value = _lib # test repo = Repository(path) repo.open() # validation lib.assert_called_with() _lib.Gio.File.new_for_path.assert_called_once_with(path) _lib.OSTree.Repo.new.assert_called_once_with(fp) lib_repo.open.assert_called_once_with(None) self.assertFalse(lib_repo.create.called)
def test_list_refs(self, lib, ref): path = '/tmp/path-1' commits = [ (1, [{'version': 1}]), (2, [{'version': 2}]) ] refs = ( 2, { 'branch:1': 'commit:1', 'branch:2': 'commit:2' } ) _lib = Mock() lib_repo = Mock() lib_repo.list_refs.return_value = refs lib_repo.load_variant.side_effect = commits _lib.OSTree.ObjectType.COMMIT = 'COMMIT' lib.return_value = _lib ref_objects = [Mock(), Mock()] ref.side_effect = ref_objects # test repo = Repository(path) repo.open = Mock() repo.impl = lib_repo listed = repo.list_refs() # validation lib.assert_called_with() repo.open.assert_called_once_with() lib_repo.list_refs.assert_called_once_with(None, None) self.assertEqual( ref.call_args_list, [ (('branch:1', 'commit:1', {'version': 1}), {}), (('branch:2', 'commit:2', {'version': 2}), {}), ]) self.assertEqual( lib_repo.load_variant.call_args_list, [ (('COMMIT', 'commit:1'), {}), (('COMMIT', 'commit:2'), {}), ]) self.assertEqual(listed, ref_objects)