diff --git a/commentaries/test_views.py b/commentaries/test_views.py index 178944ae1073312213ed5a0503534b5be6813d62..e6cc591f82f92345fe466d9dad9a23fe0d24063f 100644 --- a/commentaries/test_views.py +++ b/commentaries/test_views.py @@ -1,12 +1,9 @@ from django.contrib.auth.models import Group from django.core.urlresolvers import reverse -from django.core.management import call_command -from django.test import Client, TestCase - -# from .views import request_commentary +from django.test import TestCase class RequestCommentaryTest(TestCase): - """Test cases for request_commentary view method""" + """Test cases for `request_commentary` view method""" fixtures = ['permissions', 'groups', 'contributors'] def setUp(self): @@ -23,7 +20,10 @@ class RequestCommentaryTest(TestCase): # Registered Contributor should get 200 self.client.login(username="Test", password="testpw") request = self.client.get(self.view_url) - self.assertEquals( - request.status_code, 200, - 'Get request on request_commentary has failed' - ) + self.assertEquals(request.status_code, 200) + + def test_post_invalid_forms(self): + """Test different kind of invalid RequestCommentaryForm submits""" + self.client.login(username="Test", password="testpw") + request = self.client.post(self.view_url) + self.assertEquals(request.status_code, 200) diff --git a/commentaries/views.py b/commentaries/views.py index a21319d0cfad2104ca8f86379183c2a2eadc09ad..506fd838fc126d015f7c7144b29e4f73a4340b0f 100644 --- a/commentaries/views.py +++ b/commentaries/views.py @@ -35,44 +35,6 @@ def request_commentary(request): form = RequestCommentaryForm(request.POST or None, user=request.user) if request.method == 'POST': if form.is_valid(): - # errormessage = '' - # existing_commentary = None - # if not form.cleaned_data['arxiv_identifier'] and not form.cleaned_data['pub_DOI']: - # errormessage = ('You must provide either a DOI (for a published paper) ' - # 'or an arXiv identifier (for a preprint).') - # elif (form.cleaned_data['arxiv_identifier'] and - # (Commentary.objects - # .filter(arxiv_identifier=form.cleaned_data['arxiv_identifier']).exists())): - # errormessage = 'There already exists a Commentary Page on this preprint, see' - # existing_commentary = get_object_or_404( - # Commentary, - # arxiv_identifier=form.cleaned_data['arxiv_identifier']) - # elif (form.cleaned_data['pub_DOI'] and - # Commentary.objects.filter(pub_DOI=form.cleaned_data['pub_DOI']).exists()): - # errormessage = 'There already exists a Commentary Page on this publication, see' - # existing_commentary = get_object_or_404(Commentary, pub_DOI=form.cleaned_data['pub_DOI']) - - # Otherwise we can create the Commentary - # contributor = Contributor.objects.get(user=request.user) - # commentary = Commentary( - # requested_by = contributor, - # type = form.cleaned_data['type'], - # discipline = form.cleaned_data['discipline'], - # domain = form.cleaned_data['domain'], - # subject_area = form.cleaned_data['subject_area'], - # pub_title = form.cleaned_data['pub_title'], - # arxiv_identifier = form.cleaned_data['arxiv_identifier'], - # pub_DOI = form.cleaned_data['pub_DOI'], - # metadata = form.cleaned_data['metadata'], - # author_list = form.cleaned_data['author_list'], - # journal = form.cleaned_data['journal'], - # volume = form.cleaned_data['volume'], - # pages = form.cleaned_data['pages'], - # pub_date = form.cleaned_data['pub_date'], - # pub_abstract = form.cleaned_data['pub_abstract'], - # latest_activity = timezone.now(), - # ) - commentary = form.save(commit=False) commentary.parse_links_into_urls() commentary.save()