SciPost Code Repository

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

Use reverse instead of hardcoding urls in theses/test_views.py

parent e06a8e8e
No related branches found
No related tags found
No related merge requests found
from django.test import TestCase from django.test import TestCase, RequestFactory
from django.test.client import Client from django.test.client import Client
from django.contrib.auth.models import AnonymousUser
from django.urls import reverse
from .views import request_thesislink, RequestThesisLink
from scipost.factories import UserFactory
from .factories import ThesisLinkFactory
from .models import ThesisLink
class TestThesisDetail(TestCase): class TestThesisDetail(TestCase):
fixtures = ['groups', 'permissions']
def test_visits_valid_thesis_detail(self):
thesis_link = ThesisLinkFactory()
client = Client()
target = reverse('theses:thesis', kwargs={'thesislink_id': thesis_link.id})
response = client.post(target)
self.assertEqual(response.status_code, 200)
def test_acknowledges_after_submitting_comment(self):
class TestRequestThesisLink(TestCase):
fixtures = ['groups', 'permissions']
def test_response_when_not_logged_in(self):
'''A visitor that is not logged in cannot view this page.'''
client = Client() client = Client()
response = client.post('/theses/1') response = client.get('/theses/request_thesislink')
self.assertEqual(response.get('location'), 'bladiebla') self.assertEqual(response.status_code, 403)
def test_response_when_logged_in(self):
request = RequestFactory().get('/theses/request_thesislink')
request.user = UserFactory()
response = request_thesislink(request)
self.assertEqual(response.status_code, 200)
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