|
|
- from django.test import TestCase
- from django.conf import settings
-
- from .models import HonoraryCertificate
-
- # Create your tests here.
- class TestGranted(TestCase):
-
- def setUp(self):
- #this supress an unwanted warning about missing root dir
- settings.WHITENOISE_AUTOREFRESH = True
-
- def test_set_granted(self):
- '''test if the model function set_granted() works as intended'''
- obj = HonoraryCertificate.objects.create(realname='hurzel',email='hurzel@web.de')
- self.assertEqual(obj.granted,None)
- HonoraryCertificate.set_granted(obj.pk, True)
- obj2 = HonoraryCertificate.objects.get(pk=obj.pk)
- self.assertEqual(obj2.granted,True)
-
- def test_source_link(self):
- '''test if link to source code is included in main page'''
- response = self.client.get('', follow=True)
- #print (response.content)
- self.assertContains(response,'<a href="https://srcsrv.wikimedia.de/beba/foerderbarometer">Sourcecode</a>')
-
- def test_access_denied(self):
- '''test if /intern redirects to login page if not logged in'''
- response = self.client.get('/intern', follow=True)
- self.assertContains(response,'password')
|