Exemplo n.º 1
0
    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()
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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()
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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()
Exemplo n.º 6
0
    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)
Exemplo n.º 7
0
    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)
Exemplo n.º 8
0
    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()
Exemplo n.º 9
0
    def test_close(self):
        repository = Repository('')
        repository.impl = Mock()

        # test
        repository.close()

        # validation
        self.assertEqual(repository.impl, None)
Exemplo n.º 10
0
    def test_close(self):
        repository = Repository('')
        repository.impl = Mock()

        # test
        repository.close()

        # validation
        self.assertEqual(repository.impl, None)
Exemplo n.º 11
0
    def test_already_created(self, lib):
        path = '/tmp/path-1'
        _lib = Mock()
        lib.return_value = _lib

        # test
        repo = Repository(path)
        repo.impl = Mock()
        repo.create()

        # validation
        self.assertFalse(_lib.OSTree.Repo.new.called)
Exemplo n.º 12
0
    def test_already_created(self, lib):
        path = '/tmp/path-1'
        _lib = Mock()
        lib.return_value = _lib

        # test
        repo = Repository(path)
        repo.impl = Mock()
        repo.create()

        # validation
        self.assertFalse(_lib.OSTree.Repo.new.called)
Exemplo n.º 13
0
    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)