SciPost Code Repository

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

Add valid `VetCommentaryForm` test

Add valid test for accepted `VetCommentaryForm`.
Further added factory for unvetted Commentary.
parent 6e0a05b3
No related branches found
No related tags found
No related merge requests found
......@@ -32,3 +32,7 @@ class EmptyCommentaryFactory(CommentaryFactory):
class VettedCommentaryFactory(CommentaryFactory):
vetted = True
class UnVettedCommentaryFactory(CommentaryFactory):
vetted = False
......@@ -2,11 +2,31 @@ from django.test import TestCase
from scipost.factories import UserFactory
from .factories import VettedCommentaryFactory
from .forms import RequestCommentaryForm
from .factories import VettedCommentaryFactory, UnVettedCommentaryFactory
from .forms import RequestCommentaryForm, VetCommentaryForm
from common.helpers import model_form_data
class TestVetCommentaryForm(TestCase):
fixtures = ['permissions', 'groups']
def setUp(self):
self.commentary = UnVettedCommentaryFactory.create()
self.user = UserFactory()
def test_valid_form(self):
"""Test valid form data and return Commentary when accepted"""
form_data = {
'action_option': VetCommentaryForm.ACTION_ACCEPT,
'refusal_reason': VetCommentaryForm.REFUSAL_EMPTY,
'email_response_field': 'Lorem Ipsum'
}
print( form_data)
form = VetCommentaryForm(form_data, commentary_id=self.commentary.id, user=self.user)
print(form.errors)
self.assertTrue(form.is_valid())
class TestRequestCommentaryForm(TestCase):
fixtures = ['permissions', 'groups']
......
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