Add test2

This commit is contained in:
alazo 2018-05-23 15:17:03 +02:00
parent 326def22e5
commit 729bc1bea1
6 changed files with 39 additions and 93 deletions

View file

@ -1,12 +1,19 @@
import os
from django.db.models import Sum
from django.conf import settings
from django.contrib.auth.models import User
from django.core import mail
from django.test import TestCase, override_settings
from django.test import TestCase, Client
from django.urls import reverse
# Create your tests here.
from cms.models import Domaine, Processus, Module
class PdfTestCase(TestCase):
fixtures = ['enseignant.json', 'domaine.json', 'processus.json', 'module.json']
@classmethod
def setUpTestData(cls):
@ -14,13 +21,33 @@ class PdfTestCase(TestCase):
User.objects.create_superuser('me', 'me@example.org', 'mepassword')
def setUp(self):
self.client = Client()
self.client.login(username='me', password='mepassword')
def test_index(self):
response = self.client.get('')
self.assertGreater(len(response.content), 200)
def test_plan_pdf(self):
response = self.client.get(reverse('plan-pdf'))
self.assertEqual(
response['Content-Disposition'],
'attachment; filename="plan_formation.pdf"'
response['content-disposition'],
'attachment; filename="EDS_plan_formation.pdf"'
)
self.assertEqual(response['Content-Type'], 'application/pdf')
self.assertEqual(response['content-type'], 'application/pdf')
self.assertGreater(len(response.content), 200)
def test_periode_presentiel(self):
tot = 0
for m in Module.objects.all():
tot += m.total_presentiel
tot = Module.objects.aggregate(Sum('total_presentiel'))
self.assertEqual(tot, 1200)
def test_periode_pratique(self):
tot = Module.objects.aggregate(Sum('pratique_prof'))
self.assertEqual(tot['pratique_prof__sum'], 1200)
def test_periode_travail_perso(self):
tot = Module.objects.aggregate(Sum('travail_perso'))
self.assertEqual(tot['travail_perso__sum'], 1200)