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)
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)
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)
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)