<commit_before># -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django import test

from model_mommy import mommy
import mock

from django_cradmin import cradmin_testhelpers

from devilry.devilry_admin.views.period import overview_all_results
from devilry.devilry_dbcache import customsql
from devilry.project.common import settings


class TestOverviewAllResults(test.TestCase, cradmin_testhelpers.TestCaseMixin):
    viewclass = overview_all_results.RelatedStudentsAllResultsOverview

    def setUp(self):
        customsql.AssignmentGroupDbCacheCustomSql().initialize()

    def test_title(self):
        testperiod = mommy.make('core.Period')
        testuser = mommy.make(settings.AUTH_USER_MODEL)
        mockresponse = self.mock_http200_getrequest_htmls(
            cradmin_role=testperiod,
            requestuser=testuser
        )
        self.assertEquals('All students results', mockresponse.selector.one('title').alltext_normalized)

    def test_table_class(self):
        testperiod = mommy.make('core.Period')
        testuser = mommy.make(settings.AUTH_USER_MODEL)
        mockresponse = self.mock_http200_getrequest_htmls(
            cradmin_role=testperiod,
            requestuser=testuser
        )
        self.assertTrue(mockresponse.selector.one('.devilry-tabulardata-list'))

    def test_table_no_students(self):
        testperiod = mommy.make('core.Period')
        testuser = mommy.make(settings.AUTH_USER_MODEL)
        mockresponse = self.mock_http200_getrequest_htmls(
            cradmin_role=testperiod,
            requestuser=testuser
        )
        self.assertFalse(mockresponse.selector.exists('.devilry-tabulardata-list'))
        self.assertEquals(
            'No students on period',
            mockresponse.selector.one('.django-cradmin-listbuilderview-no-items-message').alltext_normalized)
<commit_msg>devilry_admin/tests/period/test_overview_all_results.py: Added a few tests for the view.<commit_after># -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django import test

from model_mommy import mommy
import mock

from django_cradmin import cradmin_testhelpers

from devilry.devilry_admin.views.period import overview_all_results
from devilry.devilry_dbcache import customsql
from devilry.project.common import settings


class TestOverviewAllResults(test.TestCase, cradmin_testhelpers.TestCaseMixin):
    viewclass = overview_all_results.RelatedStudentsAllResultsOverview

    def setUp(self):
        customsql.AssignmentGroupDbCacheCustomSql().initialize()

    def test_title(self):
        testperiod = mommy.make('core.Period')
        testuser = mommy.make(settings.AUTH_USER_MODEL)
        mockresponse = self.mock_http200_getrequest_htmls(
            cradmin_role=testperiod,
            requestuser=testuser
        )
        self.assertEquals('All students results', mockresponse.selector.one('title').alltext_normalized)

    def test_table_class(self):
        testperiod = mommy.make('core.Period')
        testuser = mommy.make(settings.AUTH_USER_MODEL)
        mommy.make('core.RelatedStudent', period=testperiod)
        mockresponse = self.mock_http200_getrequest_htmls(
            cradmin_role=testperiod,
            requestuser=testuser
        )
        self.assertTrue(mockresponse.selector.one('.devilry-tabulardata-list'))

    def test_table_no_students(self):
        testperiod = mommy.make('core.Period')
        testuser = mommy.make(settings.AUTH_USER_MODEL)
        mockresponse = self.mock_http200_getrequest_htmls(
            cradmin_role=testperiod,
            requestuser=testuser
        )
        self.assertFalse(mockresponse.selector.exists('.devilry-tabulardata-list'))
        self.assertEquals(
            'No students on period',
            mockresponse.selector.one('.django-cradmin-listbuilderview-no-items-message').alltext_normalized)

{'fraction_non_alphanumeric': 0.08444902162718847, 'fraction_numerical': 0.005149330587023687, 'mean_word_length': 3.522700814901048, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5759704', 'n_tokens_mistral': 1141, 'n_tokens_neox': 1119, 'n_words': 175}