Пример #1
0
 def test_init_repository_exception(self, fake_lib):
     fake_lib.LibError = LibError
     fake_lib.Repository.side_effect = LibError
     try:
         Create._init_repository('', '', '')
         self.assertTrue(False, msg='Create exception expected')
     except PulpCodedException, pe:
         self.assertEqual(pe.error_code, errors.OST0001)
Пример #2
0
 def test_init_repository_exception(self, fake_lib):
     fake_lib.LibError = LibError
     fake_lib.Repository.side_effect = LibError
     try:
         Create._init_repository('', '', '')
         self.assertTrue(False, msg='Create exception expected')
     except PulpCodedException, pe:
         self.assertEqual(pe.error_code, errors.OST0001)
Пример #3
0
 def test_process_main_repository_exception(self, fake_lib):
     fake_lib.LibError = LibError
     fake_lib.Repository.side_effect = LibError
     step = Create()
     step.parent = Mock(feed_url='', remote_id='')
     with self.assertRaises(PulpCodedException) as assertion:
         step.process_main()
         self.assertEqual(assertion.exception.error_code, errors.OST0001)
Пример #4
0
 def test_process_main_repository_exception(self, fake_lib):
     fake_lib.LibError = LibError
     fake_lib.Repository.side_effect = LibError
     try:
         step = Create()
         step.parent = Mock(feed_url='', remote_id='')
         step.process_main()
         self.assertTrue(False, msg='Create exception expected')
     except PulpCodedException, pe:
         self.assertEqual(pe.error_code, errors.OST0001)
Пример #5
0
 def test_process_main_repository_exception(self, fake_lib):
     fake_lib.LibError = LibError
     fake_lib.Repository.side_effect = LibError
     try:
         step = Create()
         step.parent = Mock(feed_url='', remote_id='')
         step.process_main()
         self.assertTrue(False, msg='Create exception expected')
     except PulpCodedException, pe:
         self.assertEqual(pe.error_code, errors.OST0001)
Пример #6
0
    def test_init_repository_exists(self, fake_lib):
        url = 'url-123'
        remote_id = 'remote-123'
        path = 'root/path-123'

        # test
        Create._init_repository(path, remote_id, url)

        # validation
        fake_lib.Repository.assert_called_once_with(path)
        fake_lib.Repository.return_value.open.assert_called_once_with()
        self.assertFalse(fake_lib.Repository.return_value.add_remote.called)
Пример #7
0
    def test_init_repository(self, fake_lib):
        url = 'url-123'
        remote_id = 'remote-123'
        path = 'root/path-123'

        # test
        Create._init_repository(path, remote_id, url)

        # validation
        fake_lib.Repository.assert_called_once_with(path)
        fake_lib.Repository().create.assert_called_once_with()
        fake_lib.Repository().add_remote.assert_called_once_with(remote_id, url)
Пример #8
0
    def test_init_repository_exists(self, fake_lib):
        url = 'url-123'
        remote_id = 'remote-123'
        path = 'root/path-123'

        # test
        Create._init_repository(path, remote_id, url)

        # validation
        fake_lib.Repository.assert_called_once_with(path)
        fake_lib.Repository.return_value.open.assert_called_once_with()
        self.assertFalse(fake_lib.Repository.return_value.add_remote.called)
Пример #9
0
    def test_init_repository(self, fake_lib):
        url = 'url-123'
        remote_id = 'remote-123'
        path = 'root/path-123'

        fake_lib.LibError = LibError
        fake_lib.Repository.return_value.open.side_effect = LibError

        # test
        Create._init_repository(path, remote_id, url)

        # validation
        fake_lib.Repository.assert_called_once_with(path)
        fake_lib.Repository.return_value.create.assert_called_once_with()
        fake_lib.Repository.return_value.add_remote.assert_called_once_with(remote_id, url)
Пример #10
0
    def test_init_repository_exists(self, fake_remote, fake_lib):
        url = 'url-123'
        remote_id = 'remote-123'
        repo_id = 'repo-xyz'
        path = 'root/path-123'

        # test
        step = Create()
        step.parent = Mock(feed_url=url, remote_id=remote_id, repo_id=repo_id)
        step._init_repository(path)

        # validation
        fake_remote.assert_called_once_with(step, fake_lib.Repository.return_value)
        fake_lib.Repository.assert_called_once_with(path)
        fake_lib.Repository.return_value.open.assert_called_once_with()
        fake_remote.return_value.add.assert_called_once_with()
Пример #11
0
    def test_init_repository(self, fake_lib):
        url = 'url-123'
        remote_id = 'remote-123'
        path = 'root/path-123'

        fake_lib.LibError = LibError
        fake_lib.Repository.return_value.open.side_effect = LibError

        # test
        Create._init_repository(path, remote_id, url)

        # validation
        fake_lib.Repository.assert_called_once_with(path)
        fake_lib.Repository.return_value.create.assert_called_once_with()
        fake_lib.Repository.return_value.add_remote.assert_called_once_with(
            remote_id, url)
Пример #12
0
    def test_process_main_repository_exists(self, fake_remote, fake_lib):
        url = "url-123"
        remote_id = "remote-123"
        repo_id = "repo-xyz"
        path = "root/path-123"
        parent = Mock(feed_url=url, remote_id=remote_id, repo_id=repo_id, storage_dir="root/path-123")

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

        # validation
        fake_remote.assert_called_once_with(step, fake_lib.Repository.return_value)
        fake_lib.Repository.assert_called_once_with(path)
        fake_lib.Repository.return_value.open.assert_called_once_with()
        fake_remote.return_value.add.assert_called_once_with()
Пример #13
0
    def test_process_main(self, fake_mkdir):
        url = 'url-123'
        remote_id = 'remote-123'
        path = 'root/path-123'

        # test
        step = Create()
        step.parent = Mock(storage_path=path, feed_url=url, remote_id=remote_id)
        step._init_repository = Mock()
        step.process_main()

        # validation
        self.assertEqual(
            fake_mkdir.call_args_list,
            [
                ((path,), {}),
                ((os.path.join(os.path.dirname(path), constants.LINKS_DIR),), {})
            ])
        step._init_repository.assert_called_with(path, remote_id, url)
Пример #14
0
    def test_process_main(self, fake_remote, fake_lib):
        url = "url-123"
        remote_id = "remote-123"
        repo_id = "repo-123"
        parent = Mock(feed_url=url, remote_id=remote_id, repo_id=repo_id, storage_dir="root/path-123")

        fake_lib.LibError = LibError
        fake_lib.Repository.return_value.open.side_effect = LibError

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

        # validation
        fake_remote.assert_called_once_with(step, fake_lib.Repository.return_value)
        fake_lib.Repository.assert_called_once_with(parent.storage_dir)
        fake_lib.Repository.return_value.open.assert_called_once_with()
        fake_lib.Repository.return_value.create.assert_called_once_with()
        fake_remote.return_value.add.assert_called_once_with()
Пример #15
0
    def test_process_main_repository_exists(self, fake_remote, fake_lib):
        url = 'url-123'
        remote_id = 'remote-123'
        repo_id = 'repo-xyz'
        path = 'root/path-123'
        parent = Mock(feed_url=url,
                      remote_id=remote_id,
                      repo_id=repo_id,
                      storage_dir='root/path-123')

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

        # validation
        fake_remote.assert_called_once_with(step,
                                            fake_lib.Repository.return_value)
        fake_lib.Repository.assert_called_once_with(path)
        fake_lib.Repository.return_value.open.assert_called_once_with()
        fake_remote.return_value.add.assert_called_once_with()
Пример #16
0
    def test_process_main(self, fake_remote, fake_lib):
        url = 'url-123'
        remote_id = 'remote-123'
        repo_id = 'repo-123'
        parent = Mock(feed_url=url,
                      remote_id=remote_id,
                      repo_id=repo_id,
                      storage_dir='root/path-123')

        fake_lib.LibError = LibError
        fake_lib.Repository.return_value.open.side_effect = LibError

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

        # validation
        fake_remote.assert_called_once_with(step,
                                            fake_lib.Repository.return_value)
        fake_lib.Repository.assert_called_once_with(parent.storage_dir)
        fake_lib.Repository.return_value.open.assert_called_once_with()
        fake_lib.Repository.return_value.create.assert_called_once_with()
        fake_remote.return_value.add.assert_called_once_with()
Пример #17
0
    def test_process_main(self, fake_mkdir):
        url = 'url-123'
        remote_id = 'remote-123'
        path = 'root/path-123'

        # test
        step = Create()
        step.parent = Mock(storage_path=path,
                           feed_url=url,
                           remote_id=remote_id)
        step._init_repository = Mock()
        step.process_main()

        # validation
        self.assertEqual(fake_mkdir.call_args_list, [
            ((path, ), {}),
            ((os.path.join(os.path.dirname(path), constants.LINKS_DIR), ), {})
        ])
        step._init_repository.assert_called_with(path, remote_id, url)
Пример #18
0
 def test_init(self):
     step = Create()
     self.assertEqual(step.step_id, constants.IMPORT_STEP_CREATE_REPOSITORY)
     self.assertTrue(step.description is not None)