SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit c5b384fe authored by Geert Kapteijns's avatar Geert Kapteijns
Browse files

Add test for creating comment for ThesisLink

parent 23d9e81a
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ from django.contrib.messages.storage.fallback import FallbackStorage ...@@ -10,6 +10,7 @@ from django.contrib.messages.storage.fallback import FallbackStorage
from scipost.factories import UserFactory, ContributorFactory from scipost.factories import UserFactory, ContributorFactory
from comments.factories import CommentFactory from comments.factories import CommentFactory
from comments.forms import CommentForm from comments.forms import CommentForm
from comments.models import Comment
from .views import RequestThesisLink, VetThesisLinkRequests, thesis_detail from .views import RequestThesisLink, VetThesisLinkRequests, thesis_detail
from .factories import ThesisLinkFactory, VetThesisLinkFormFactory from .factories import ThesisLinkFactory, VetThesisLinkFormFactory
from .models import ThesisLink from .models import ThesisLink
...@@ -29,17 +30,21 @@ class TestThesisDetail(TestCase): ...@@ -29,17 +30,21 @@ class TestThesisDetail(TestCase):
def test_submitting_comment_creates_comment(self): def test_submitting_comment_creates_comment(self):
""" Valid Comment gets saved """ """ Valid Comment gets saved """
contributor = ContributorFactory() contributor = ContributorFactory()
thesislink = ThesisLinkFactory() thesislink = ThesisLinkFactory()
valid_comment_data = model_form_data(CommentFactory(), CommentForm) valid_comment_data = model_form_data(CommentFactory.build(), CommentForm)
target = reverse('theses:thesis', kwargs={'thesislink_id': thesislink.id}) target = reverse('theses:thesis', kwargs={'thesislink_id': thesislink.id})
comment_count = Comment.objects.filter(author=contributor).count()
self.assertEqual(comment_count, 0)
request = RequestFactory().post(target, valid_comment_data) request = RequestFactory().post(target, valid_comment_data)
request.user = contributor.user request.user = contributor.user
response = thesis_detail(request, thesislink_id=thesislink.id) response = thesis_detail(request, thesislink_id=thesislink.id)
print(response)
self.assertTrue(False) comment_count = Comment.objects.filter(author=contributor).count()
self.assertEqual(comment_count, 1)
class TestRequestThesisLink(TestCase): class TestRequestThesisLink(TestCase):
......
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