SciPost Code Repository

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

Add tests for commentaries browse

Basic tests to check response contains commentaires.
parent 06da1e9d
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ import factory
from .models import Commentary, COMMENTARY_TYPES
from scipost.constants import SCIPOST_DISCIPLINES, SCIPOST_SUBJECT_AREAS
from scipost.constants import DISCIPLINE_PHYSICS, SCIPOST_SUBJECT_AREAS
from scipost.factories import ContributorFactory
from journals.models import SCIPOST_JOURNALS_DOMAINS
......@@ -15,7 +15,7 @@ class CommentaryFactory(factory.django.DjangoModelFactory):
requested_by = factory.SubFactory(ContributorFactory)
vetted_by = factory.SubFactory(ContributorFactory)
type = COMMENTARY_TYPES[0][0]
discipline = SCIPOST_DISCIPLINES[0][0]
discipline = DISCIPLINE_PHYSICS
domain = SCIPOST_JOURNALS_DOMAINS[0][0]
subject_area = SCIPOST_SUBJECT_AREAS[0][1][0][0]
pub_title = factory.Sequence(lambda n: "Commentary %d" % n)
......
from django.test import TestCase
# from django.test import TestCase
......@@ -5,6 +5,7 @@ from django.test import TestCase
from scipost.factories import ContributorFactory
from .factories import UnVettedCommentaryFactory, VettedCommentaryFactory
from .forms import CommentarySearchForm
from .models import Commentary
......@@ -85,3 +86,25 @@ class VetCommentaryRequestsTest(TestCase):
UnVettedCommentaryFactory()
response = self.client.get(self.view_url)
self.assertTrue(type(response.context['commentary_to_vet']) is Commentary)
class BrowseCommentariesTest(TestCase):
"""Test cases for `browse` view."""
fixtures = ['groups', 'permissions']
def setUp(self):
VettedCommentaryFactory(discipline='physics')
self.view_url = reverse('commentaries:browse', kwargs={
'discipline': 'physics',
'nrweeksback': '1'
})
def test_response_list(self):
'''Test if the browse view is passing commentaries to anoymous users.'''
response = self.client.get(self.view_url)
self.assertEquals(response.status_code, 200)
# The created vetted Commentary is found!
self.assertTrue(response.context['commentary_browse_list'].count() >= 1)
# The search form is passed trough the view...
self.assertTrue(type(response.context['form']) is CommentarySearchForm)
......@@ -3,10 +3,10 @@ DISCIPLINE_ASTROPHYSICS = 'astrophysics'
DISCIPLINE_MATH = 'mathematics'
DISCIPLINE_COMPUTERSCIENCE = 'computerscience'
SCIPOST_DISCIPLINES = (
('physics', 'Physics'),
('astrophysics', 'Astrophysics'),
('mathematics', 'Mathematics'),
('computerscience', 'Computer Science'),
(DISCIPLINE_PHYSICS, 'Physics'),
(DISCIPLINE_ASTROPHYSICS, 'Astrophysics'),
(DISCIPLINE_MATH, 'Mathematics'),
(DISCIPLINE_COMPUTERSCIENCE, 'Computer Science'),
)
disciplines_dict = dict(SCIPOST_DISCIPLINES)
......
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