Skip to content
Snippets Groups Projects
test_statistics.py 1013 B
Newer Older
# coding=utf-8
from datetime import datetime

from django.urls import reverse

from web.tests import LoggedInTestCase
__author__ = 'Valentin Grouès'
class TestStatisticsView(LoggedInTestCase):
    def test_statistics_request(self):
        self.login_as_admin()
        url = reverse('web.views.statistics')
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        current_month = datetime.now().month - 1 or 12
Jacek Lebioda's avatar
Jacek Lebioda committed
        content = response.content.decode('utf8')
        self.assertIn('<option value="{}" selected>'.format(current_month), content)
        response = self.client.get(url, {"month": 10, "year": 2017, "subject_type": -1, "visit": -1})
Jacek Lebioda's avatar
Jacek Lebioda committed
        content = response.content.decode('utf8')
        self.assertIn('<option value="10" selected>October', content)

    def test_statistics_request_without_permission(self):
        url = reverse('web.views.statistics')
        response = self.client.get(url)
        self.assertEqual(response.status_code, 302)