예제 #1
0
    def test_process_main(self, fake_lib):
        refs = [
            Mock(),
            Mock(),
            Mock()
        ]
        remote = Mock()
        remote.list_refs.return_value = refs
        lib_repository = Mock()
        repository = Mock(id='1234')
        fake_lib.Remote.return_value = remote
        fake_lib.Repository.return_value = lib_repository
        parent = Mock(storage_dir='/tmp/xx', repo_id=repository.id)
        parent.get_repo.return_value = repository

        # test
        step = Summary()
        step.parent = parent
        step.process_main()

        # validation
        fake_lib.Repository.assert_called_once_with(step.parent.storage_dir)
        fake_lib.Remote.assert_called_once_with(step.parent.repo_id, lib_repository)
        repository.scratchpad.update.assert_called_once_with(
            {
                constants.REMOTE: {
                    constants.SUMMARY: [r.dict() for r in remote.list_refs.return_value]
                }
            })
        repository.save.assert_called_once_with()
예제 #2
0
    def test_process_main_fetch_failed(self, fake_lib):
        remote = Mock()
        remote.list_refs.side_effect = LibError
        lib_repository = Mock()
        repository = Mock(id='1234')
        fake_lib.Remote.return_value = remote
        fake_lib.Repository.return_value = lib_repository
        fake_lib.LibError = LibError
        parent = Mock(storage_dir='/tmp/xx', repo_id=repository.id)
        parent.get_repo.return_value = repository

        # test and validation
        step = Summary()
        step.parent = parent
        with self.assertRaises(PulpCodedException) as assertion:
            step.process_main()
            self.assertEqual(assertion.exception.error_code, errors.OST0005)
예제 #3
0
    def test_process_main_fetch_failed(self, fake_lib):
        remote = Mock()
        remote.list_refs.side_effect = LibError
        lib_repository = Mock()
        repository = Mock(id='1234')
        fake_lib.Remote.return_value = remote
        fake_lib.Repository.return_value = lib_repository
        fake_lib.LibError = LibError
        parent = Mock(storage_dir='/tmp/xx', repo_id=repository.id)
        parent.get_repo.return_value = repository

        # test and validation
        step = Summary()
        step.parent = parent
        try:
            step.process_main()
            self.assertTrue(False, msg='Fetch exception expected')
        except PulpCodedException, pe:
            self.assertEqual(pe.error_code, errors.OST0005)
예제 #4
0
    def test_process_main_fetch_failed(self, fake_lib):
        remote = Mock()
        remote.list_refs.side_effect = LibError
        lib_repository = Mock()
        repository = Mock(id="1234")
        fake_lib.Remote.return_value = remote
        fake_lib.Repository.return_value = lib_repository
        fake_lib.LibError = LibError
        parent = Mock(storage_dir="/tmp/xx", repo_id=repository.id)
        parent.get_repo.return_value = repository

        # test and validation
        step = Summary()
        step.parent = parent
        try:
            step.process_main()
            self.assertTrue(False, msg="Fetch exception expected")
        except PulpCodedException, pe:
            self.assertEqual(pe.error_code, errors.OST0005)
예제 #5
0
    def test_process_main(self, fake_lib):
        refs = [
            Mock(),
            Mock(),
            Mock(),
        ]
        ref_dicts = [
            {'commit': 'abc', 'name': 'foo', 'metadata': {'a.b': 'x'}},
            {'commit': 'def', 'name': 'bar', 'metadata': {'a.b': 'y'}},
            {'commit': 'hij', 'name': 'baz', 'metadata': {'a.b': 'z'}},
        ]
        for ref, d in zip(refs, ref_dicts):
            ref.dict.return_value = d
        remote = Mock()
        remote.list_refs.return_value = refs
        lib_repository = Mock()
        repository = Mock(id='1234')
        fake_lib.Remote.return_value = remote
        fake_lib.Repository.return_value = lib_repository
        parent = Mock(storage_dir='/tmp/xx', repo_id=repository.id)
        parent.get_repo.return_value = repository

        # test
        step = Summary()
        step.parent = parent
        step.process_main()

        # validation
        fake_lib.Repository.assert_called_once_with(step.parent.storage_dir)
        fake_lib.Remote.assert_called_once_with(step.parent.repo_id, lib_repository)
        repository.repo_obj.scratchpad.update.assert_called_once_with(
            {
                constants.REMOTE: {
                    constants.SUMMARY: [
                        {'commit': 'abc', 'name': 'foo', 'metadata': {'a-b': 'x'}},
                        {'commit': 'def', 'name': 'bar', 'metadata': {'a-b': 'y'}},
                        {'commit': 'hij', 'name': 'baz', 'metadata': {'a-b': 'z'}},
                    ]
                }
            })
        repository.repo_obj.save.assert_called_once_with()
예제 #6
0
    def test_process_main(self, fake_lib):
        refs = [Mock(), Mock(), Mock()]
        ref_dicts = [
            {"commit": "abc", "name": "foo", "metadata": {"a.b": "x"}},
            {"commit": "def", "name": "bar", "metadata": {"a.b": "y"}},
            {"commit": "hij", "name": "baz", "metadata": {"a.b": "z"}},
        ]
        for ref, d in zip(refs, ref_dicts):
            ref.dict.return_value = d
        remote = Mock()
        remote.list_refs.return_value = refs
        lib_repository = Mock()
        repository = Mock(id="1234")
        fake_lib.Remote.return_value = remote
        fake_lib.Repository.return_value = lib_repository
        parent = Mock(storage_dir="/tmp/xx", repo_id=repository.id)
        parent.get_repo.return_value = repository

        # test
        step = Summary()
        step.parent = parent
        step.process_main()

        # validation
        fake_lib.Repository.assert_called_once_with(step.parent.storage_dir)
        fake_lib.Remote.assert_called_once_with(step.parent.repo_id, lib_repository)
        repository.repo_obj.scratchpad.update.assert_called_once_with(
            {
                constants.REMOTE: {
                    constants.SUMMARY: [
                        {"commit": "abc", "name": "foo", "metadata": {"a-b": "x"}},
                        {"commit": "def", "name": "bar", "metadata": {"a-b": "y"}},
                        {"commit": "hij", "name": "baz", "metadata": {"a-b": "z"}},
                    ]
                }
            }
        )
        repository.repo_obj.save.assert_called_once_with()
예제 #7
0
    def test_process_main(self, fake_lib):
        refs = [
            Mock(),
            Mock(),
            Mock(),
        ]
        ref_dicts = [
            {
                'commit': 'abc',
                'name': 'foo',
                'metadata': {
                    'a.b': 'x'
                }
            },
            {
                'commit': 'def',
                'name': 'bar',
                'metadata': {
                    'a.b': 'y'
                }
            },
            {
                'commit': 'hij',
                'name': 'baz',
                'metadata': {
                    'a.b': 'z'
                }
            },
        ]
        for ref, d in zip(refs, ref_dicts):
            ref.dict.return_value = d
        remote = Mock()
        remote.list_refs.return_value = refs
        lib_repository = Mock()
        repository = Mock(id='1234')
        fake_lib.Remote.return_value = remote
        fake_lib.Repository.return_value = lib_repository
        parent = Mock(storage_dir='/tmp/xx', repo_id=repository.id)
        parent.get_repo.return_value = repository

        # test
        step = Summary()
        step.parent = parent
        step.process_main()

        # validation
        fake_lib.Repository.assert_called_once_with(step.parent.storage_dir)
        fake_lib.Remote.assert_called_once_with(step.parent.repo_id,
                                                lib_repository)
        repository.repo_obj.scratchpad.update.assert_called_once_with({
            constants.REMOTE: {
                constants.SUMMARY: [
                    {
                        'commit': 'abc',
                        'name': 'foo',
                        'metadata': {
                            'a-b': 'x'
                        }
                    },
                    {
                        'commit': 'def',
                        'name': 'bar',
                        'metadata': {
                            'a-b': 'y'
                        }
                    },
                    {
                        'commit': 'hij',
                        'name': 'baz',
                        'metadata': {
                            'a-b': 'z'
                        }
                    },
                ]
            }
        })
        repository.repo_obj.save.assert_called_once_with()