# -*- coding: utf-8 -*- import grok from waeup.kofa.testing import FunctionalTestCase from zope.component import getUtility from waeup.kofa.students.interfaces import IStudentsUtils from waeup.kofa.students.tests.test_browser import StudentsFullSetup from waeup.fceokene.testing import FunctionalLayer class BedAllocationTests(StudentsFullSetup): layer = FunctionalLayer def test_getAccommodationDetails(self): students_utils = getUtility(IStudentsUtils) acc_details = students_utils.getAccommodationDetails(self.student) self.assertEqual(acc_details['bt'], 'regular_male_fr') self.student['studycourse'].current_level = 200 acc_details = students_utils.getAccommodationDetails(self.student) self.assertEqual(acc_details['bt'], 'regular_male_re') self.student['studycourse'].current_level = 300 acc_details = students_utils.getAccommodationDetails(self.student) self.assertEqual(acc_details['bt'], 'regular_male_fi') self.student['studycourse'].current_level = 400 acc_details = students_utils.getAccommodationDetails(self.student) self.assertEqual(acc_details['bt'], 'regular_male_fi') self.student['studycourse'].current_level = 500 acc_details = students_utils.getAccommodationDetails(self.student) self.assertEqual(acc_details['bt'], 'regular_male_fi') return def test_maxCreditsExceeded(self): students_utils = getUtility(IStudentsUtils) studylevel = grok.Container() studylevel.total_credits = 40 course = grok.Model() course.credits = 18 max_credits = students_utils.maxCreditsExceeded(studylevel, course) self.assertEqual(max_credits, 0) course.credits = 19 max_credits = students_utils.maxCreditsExceeded(studylevel, course) self.assertEqual(max_credits, 58)