You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.2 KiB

4 years ago
4 years ago
4 years ago
4 years ago
  1. from django.test import TestCase
  2. from django.conf import settings
  3. from .models import HonoraryCertificate
  4. # Create your tests here.
  5. class TestGranted(TestCase):
  6. def setUp(self):
  7. #this supress an unwanted warning about missing root dir
  8. settings.WHITENOISE_AUTOREFRESH = True
  9. def test_set_granted(self):
  10. '''test if the model function set_granted() works as intended'''
  11. obj = HonoraryCertificate.objects.create(realname='hurzel',email='hurzel@web.de')
  12. self.assertEqual(obj.granted,None)
  13. HonoraryCertificate.set_granted(obj.pk, True)
  14. obj2 = HonoraryCertificate.objects.get(pk=obj.pk)
  15. self.assertEqual(obj2.granted,True)
  16. def test_source_link(self):
  17. '''test if link to source code is included in main page'''
  18. response = self.client.get('', follow=True)
  19. #print (response.content)
  20. self.assertContains(response,'<a href="https://srcsrv.wikimedia.de/beba/foerderbarometer">Sourcecode</a>')
  21. def test_access_denied(self):
  22. '''test if /intern redirects to login page if not logged in'''
  23. response = self.client.get('/intern', follow=True)
  24. self.assertContains(response,'password')