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_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)
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)
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' # 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)
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_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()
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_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()
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)
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()
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()
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()
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)
def test_init(self): step = Create() self.assertEqual(step.step_id, constants.IMPORT_STEP_CREATE_REPOSITORY) self.assertTrue(step.description is not None)