SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit c810f01f authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Add empty `_invalid_forms` test case

parent 1bf3f035
No related branches found
No related tags found
No related merge requests found
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)
......@@ -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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment