Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/3838_handle_exception #2414

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions doajtest/unit/test_view_publisher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from doajtest import helpers
from doajtest.helpers import DoajTestCase
from portality import models, constants
from portality.util import url_for


class TestViewPublisher(DoajTestCase):

def test_delete_application__no_such_object(self):
pwd = 'password'
un = 'publisher_a'
acc = models.Account.make_account(un + "@example.com", un, "Publisher " + un, [constants.ROLE_PUBLISHER])
acc.set_password(pwd)
acc.save(blocking=True)

with self.app_test.test_client() as t_client:
resp = helpers.login(t_client, acc.email, pwd)
assert resp.status_code == 200

resp = t_client.get(url_for("publisher.delete_application", application_id='no_such_id'))
assert resp.status_code == 400
8 changes: 6 additions & 2 deletions portality/view/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

from portality.app_email import EmailException
from portality import models, constants
from portality.bll.exceptions import AuthoriseException, ArticleMergeConflict, DuplicateArticleException, ArticleNotAcceptable
from portality.bll.exceptions import AuthoriseException, ArticleMergeConflict, DuplicateArticleException, \
ArticleNotAcceptable, NoSuchObjectException
from portality.decorators import ssl_required, restrict_to_role, write_required
from portality.dao import ESMappingMissingError
from portality.forms.application_forms import ApplicationFormFactory
Expand Down Expand Up @@ -54,7 +55,10 @@ def delete_application(application_id):

# otherwise delegate to the application service to sort this out
appService = DOAJ.applicationService()
appService.delete_application(application_id, current_user._get_current_object())
try:
appService.delete_application(application_id, current_user._get_current_object())
except NoSuchObjectException:
abort(400)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the response to return a 404 to ensure consistency with equivalent API requests.


return redirect(url_for("publisher.deleted_thanks"))

Expand Down
Loading