def test_find_highlight_academic_calendar(self):
        an_academic_year = AcademicYearFactory(year=timezone.now().year,
                                               start_date=timezone.now() - datetime.timedelta(days=10),
                                               end_date=timezone.now() + datetime.timedelta(days=10))

        tmp_academic_calendar_1 = AcademicCalendarFactory.build(academic_year=an_academic_year,
                                                                title="First calendar event")
        tmp_academic_calendar_1.save(functions=[])

        tmp_academic_calendar_2 = AcademicCalendarFactory.build(academic_year=an_academic_year,
                                                                title="Second calendar event")
        tmp_academic_calendar_2.save(functions=[])

        null_academic_calendar = AcademicCalendarFactory.build(academic_year=an_academic_year,
                                                               title="A third event which is null",
                                                               highlight_description=None)
        null_academic_calendar.save(functions=[])

        empty_academic_calendar = AcademicCalendarFactory.build(academic_year=an_academic_year,
                                                                title="A third event which is null",
                                                                highlight_title="")
        empty_academic_calendar.save(functions=[])

        db_academic_calendars = list(academic_calendar.find_highlight_academic_calendar())
        self.assertIsNotNone(db_academic_calendars)
        self.assertCountEqual(db_academic_calendars, [tmp_academic_calendar_1, tmp_academic_calendar_2])
    def setUp(self):
        AcademicYearFactory.produce_in_past()

        self.current_academic_yr = academic_year.current_academic_year()

        self.academic_calendar_1 = AcademicCalendarFactory.build(
            title="Submission of score encoding - 1",
            start_date=datetime.date(self.current_academic_yr.year, 10, 15),
            end_date=datetime.date(self.current_academic_yr.year + 1, 1, 1),
            academic_year=self.current_academic_yr,
            reference=academic_calendar_type.SCORES_EXAM_SUBMISSION)
        self.academic_calendar_2 = AcademicCalendarFactory.build(
            title="Submission of score encoding - 2",
            start_date=datetime.date(self.current_academic_yr.year + 1, 3, 15),
            end_date=datetime.date(self.current_academic_yr.year + 1, 6, 28),
            academic_year=self.current_academic_yr,
            reference=academic_calendar_type.SCORES_EXAM_SUBMISSION)
        self.academic_calendar_3 = AcademicCalendarFactory.build(
            title="Submission of score encoding - 3",
            start_date=datetime.date(self.current_academic_yr.year + 1, 8, 1),
            end_date=datetime.date(self.current_academic_yr.year + 1, 9, 29),
            academic_year=self.current_academic_yr,
            reference=academic_calendar_type.SCORES_EXAM_SUBMISSION)
        self.academic_calendar_4 = AcademicCalendarFactory.build(
            title="Deliberation session 1",
            start_date=datetime.date(self.current_academic_yr.year + 1, 1, 1),
            end_date=datetime.date(self.current_academic_yr.year + 1, 1, 2),
            academic_year=self.current_academic_yr,
            reference=academic_calendar_type.DELIBERATION)
        self.academic_calendar_1.save(functions=[])
        self.academic_calendar_2.save(functions=[])
        self.academic_calendar_3.save(functions=[])
        self.academic_calendar_4.save(functions=[])
Example #3
0
    def test_get_sessions_dates(self):
        from base.views.education_group import get_sessions_dates
        from base.tests.factories.session_exam_calendar import SessionExamCalendarFactory
        from base.tests.factories.academic_calendar import AcademicCalendarFactory
        from base.tests.factories.education_group_year import EducationGroupYearFactory
        from base.tests.factories.offer_year_calendar import OfferYearCalendarFactory

        sessions_quantity = 3
        an_academic_year = AcademicYearFactory()
        academic_calendar = AcademicCalendarFactory.build(
            academic_year=an_academic_year)
        academic_calendar.save(functions=[])
        education_group_year = EducationGroupYearFactory(
            academic_year=an_academic_year)
        session_exam_calendars = [
            SessionExamCalendarFactory(number_session=session,
                                       academic_calendar=academic_calendar)
            for session in range(1, sessions_quantity + 1)
        ]
        offer_year_calendar = OfferYearCalendarFactory(
            academic_calendar=academic_calendar,
            education_group_year=education_group_year)
        self.assertEquals(
            get_sessions_dates(academic_calendar.reference,
                               education_group_year), {
                                   'session{}'.format(s): offer_year_calendar
                                   for s in range(1, sessions_quantity + 1)
                               })
Example #4
0
    def test_multiple_messages_outside_encoding_period(self):
        date_format = str(_('date_format'))

        # Submission of score encoding - 1 [Two day before today]
        self.academic_calendar.end_date = timezone.now() - timedelta(days=2)
        self.academic_calendar.start_date = timezone.now() - timedelta(days=20)
        self.academic_calendar.save()

        # Create submission of score encoding - 2 [Start in 100 days]
        ac = AcademicCalendarFactory.build(title="Submission of score encoding - 2",
                                           academic_year=self.academic_year,
                                           start_date=self.academic_calendar.end_date + timedelta(days=100),
                                           end_date=self.academic_calendar.end_date + timedelta(days=130),
                                           reference=academic_calendar_type.SCORES_EXAM_SUBMISSION)
        ac.save()
        SessionExamCalendarFactory(academic_calendar=ac, number_session=number_session.TWO)

        url = reverse('scores_encoding')
        response = self.client.get(url, follow=True)
        messages = list(response.context['messages'])

        self.assertEqual(len(messages), 2)
        self.assertEqual(messages[0].tags, 'warning')
        end_date_str = self.academic_calendar.end_date.strftime(date_format)
        self.assertEqual(messages[0].message,
                         _("The period of scores' encoding %(session_number)s is closed since %(str_date)s")
                         % {'session_number': 1, 'str_date': end_date_str})
        self.assertEqual(messages[1].tags, 'warning')
        start_date_str = ac.start_date.strftime(date_format)
        self.assertEqual(messages[1].message,
                         _("The period of scores' encoding %(session_number)s will be open %(str_date)s")
                         % {'session_number': 2, 'str_date': start_date_str})
 def test_find_by_id(self):
     an_academic_year = AcademicYearFactory()
     tmp_academic_calendar = AcademicCalendarFactory.build(academic_year=an_academic_year)
     tmp_academic_calendar.save(functions=[])
     db_academic_calendar = academic_calendar.find_by_id(tmp_academic_calendar.id)
     self.assertIsNotNone(db_academic_calendar)
     self.assertEqual(db_academic_calendar, tmp_academic_calendar)
 def test_save_without_functions_args(self):
     an_academic_year = AcademicYearFactory()
     an_academic_calendar = AcademicCalendarFactory.build(academic_year=an_academic_year,
                                                          title="A calendar event",
                                                          start_date=start_date,
                                                          end_date=end_date)
     self.assertRaises(FunctionArgumentMissingException, an_academic_calendar.save)
Example #7
0
    def test_multiple_messages_outside_encoding_period(self):
        date_format = str(_('date_format'))

        # Submission of score encoding - 1 [Two day before today]
        self.academic_calendar.end_date = timezone.now() - timedelta(days=2)
        self.academic_calendar.start_date = timezone.now() - timedelta(days=20)
        self.academic_calendar.save()

        # Create submission of score encoding - 2 [Start in 100 days]
        ac = AcademicCalendarFactory.build(title="Submission of score encoding - 2",
                                           academic_year=self.academic_year,
                                           start_date=self.academic_calendar.end_date + timedelta(days=100),
                                           end_date=self.academic_calendar.end_date + timedelta(days=130),
                                           reference=academic_calendar_type.SCORES_EXAM_SUBMISSION)
        ac.save()
        SessionExamCalendarFactory(academic_calendar=ac, number_session=number_session.TWO)

        url = reverse('scores_encoding')
        response = self.client.get(url, follow=True)
        messages = list(response.context['messages'])

        self.assertEqual(len(messages), 2)
        self.assertEqual(messages[0].tags, 'warning')
        end_date_str = self.academic_calendar.end_date.strftime(date_format)
        self.assertEqual(messages[0].message, _('outside_scores_encodings_period_latest_session') % (1, end_date_str))
        self.assertEqual(messages[1].tags, 'warning')
        start_date_str = ac.start_date.strftime(date_format)
        self.assertEqual(messages[1].message, _('outside_scores_encodings_period_closest_session') % (2, start_date_str))
Example #8
0
 def test_start_date_higher_than_end_date(self):
     yr = timezone.now().year
     an_academic_year = AcademicYearFactory(year=yr)
     an_academic_calendar = AcademicCalendarFactory.build(academic_year=an_academic_year,
                                                          title="An event",
                                                          start_date=datetime.date(yr, 3, 4),
                                                          end_date=datetime.date(yr, 3, 3))
     self.assertRaises(StartDateHigherThanEndDateException, an_academic_calendar.save)
 def test_find_academic_calendar_by_academic_year_with_dates(self):
     tmp_academic_year = AcademicYearFactory(year=timezone.now().year)
     tmp_academic_calendar = AcademicCalendarFactory.build(academic_year=tmp_academic_year)
     tmp_academic_calendar.save(functions=[])
     db_academic_calendar = list(academic_calendar.find_academic_calendar_by_academic_year_with_dates
                                 (tmp_academic_year.id))[0]
     self.assertIsNotNone(db_academic_calendar)
     self.assertEqual(db_academic_calendar, tmp_academic_calendar)
Example #10
0
 def test_find_academic_calendar_by_academic_year(self):
     tmp_academic_year = AcademicYearFactory()
     tmp_academic_calendar = AcademicCalendarFactory.build(academic_year=tmp_academic_year)
     tmp_academic_calendar.save(functions=[])
     db_academic_calendar = list(academic_calendar.find_academic_calendar_by_academic_year
                                 ([tmp_academic_year][0]))[0]
     self.assertIsNotNone(db_academic_calendar)
     self.assertEqual(db_academic_calendar, tmp_academic_calendar)
Example #11
0
 def setUp(self):
     self.academic_year = AcademicYearFactory(
         year=YEAR_CALENDAR,
         start_date=datetime.date(YEAR_CALENDAR, 9, 1),
         end_date=datetime.date(YEAR_CALENDAR + 1, 10, 30))
     self.academic_calendar = AcademicCalendarFactory.build(
         academic_year=self.academic_year,
         start_date=datetime.date(YEAR_CALENDAR, 9, 1),
         end_date=datetime.date(YEAR_CALENDAR + 1, 10, 30))
     self.academic_calendar.save(functions=[])
     self.offer_year = OfferYearFactory(academic_year=self.academic_year)
Example #12
0
    def setUp(self):
        self.user = User.objects.create_user(username='******', password='******')
        add_permission(self.user, "can_access_scoreencoding")
        self.client.force_login(self.user)

        # Create context out of range
        self.academic_year = _get_academic_year()
        self.academic_calendar = AcademicCalendarFactory.build(title="Submission of score encoding - 1",
                                                          academic_year=self.academic_year,
                                                          reference=academic_calendar_type.SCORES_EXAM_SUBMISSION)
        self.academic_calendar.save(functions=[])
        self.session_exam_calendar = SessionExamCalendarFactory(academic_calendar=self.academic_calendar,
                                                                number_session=number_session.ONE)
Example #13
0
def _create_academic_calendar_with_offer_year_calendars():
    academic_yr = AcademicYearFactory(year=timezone.now().year,
                                      start_date=start_date,
                                      end_date=end_date)

    an_academic_calendar = AcademicCalendarFactory.build(
        academic_year=academic_yr,
        title="Academic year {0} - {1}".format(start_date.year,
                                               start_date.year + 1),
        description="My offerYearCalendars are not customized (default value)",
        start_date=start_date,
        end_date=end_date)
    an_academic_calendar.save(
        functions=[offer_year_calendar.save_from_academic_calendar])
    return an_academic_calendar
    def setUp(self):
        AcademicYearFactory.produce_in_past()

        self.current_academic_yr = academic_year.current_academic_year()
        self.academic_calendar = AcademicCalendarFactory.build(
            title="Deliberation session 1",
            start_date=datetime.date(self.current_academic_yr.year + 1, 1, 1),
            end_date=datetime.date(self.current_academic_yr.year + 1, 1, 2),
            academic_year=self.current_academic_yr,
            reference=academic_calendar_type.DELIBERATION)
        self.academic_calendar.save(functions=[])
        SessionExamCalendarFactory(academic_calendar=self.academic_calendar,
                                   number_session=number_session.ONE)
        self.offer_yr = OfferYearFactory(
            academic_year=self.current_academic_yr)
Example #15
0
    def setUp(self):
        self.user = User.objects.create_user(username='******', password='******')
        self.person = PersonFactory(user=self.user)
        add_permission(self.user, "can_access_scoreencoding")
        self.client.force_login(self.user)

        # Set user as program manager of two offer
        academic_year = _get_academic_year()
        self.offer_year_bio2ma = OfferYearFactory(acronym="BIO2MA", title="Master en Biologie",
                                                  academic_year=academic_year)
        self.offer_year_bio2bac = OfferYearFactory(acronym="BIO2BAC", title="Bachelier en Biologie",
                                                   academic_year=academic_year)
        ProgramManagerFactory(offer_year=self.offer_year_bio2ma, person=self.person)
        ProgramManagerFactory(offer_year=self.offer_year_bio2bac, person=self.person)

        # Create an score submission event - with an session exam
        academic_calendar = AcademicCalendarFactory.build(title="Submission of score encoding - 1",
                                                          academic_year=academic_year,
                                                          start_date=academic_year.start_date,
                                                          end_date=academic_year.end_date,
                                                          reference=academic_calendar_type.SCORES_EXAM_SUBMISSION)
        academic_calendar.save(functions=[])
        self.session_exam_calendar = SessionExamCalendarFactory(academic_calendar=academic_calendar,
                                                                number_session=number_session.ONE)

        # Offer : BIO2MA - 2 Learning unit with exam
        self.offer_year_calendar_bio2ma = OfferYearCalendarFactory(offer_year=self.offer_year_bio2ma,
                                                                   academic_calendar=academic_calendar)

        self.learning_unit_year = LearningUnitYearFactory(academic_year=academic_year)
        self.learning_unit_year_2 = LearningUnitYearFactory(academic_year=academic_year)
        self.first_session_exam = test_session_exam.create_session_exam(number_session.ONE,
                                                                        self.learning_unit_year,
                                                                        self.offer_year_bio2ma)
        self.first_session_exam_2 = test_session_exam.create_session_exam(number_session.ONE,
                                                                          self.learning_unit_year_2,
                                                                          self.offer_year_bio2ma)

        # Offer: BIO2BAC - 1 learning unit with exam
        self.offer_year_calendar_bio2bac = OfferYearCalendarFactory(offer_year=self.offer_year_bio2ma,
                                                                    academic_calendar=academic_calendar)
        self.learning_unit_year_3 = LearningUnitYearFactory(academic_year=academic_year)
        self.first_session_exam_3 = test_session_exam.create_session_exam(number_session.ONE,
                                                                          self.learning_unit_year_3,
                                                                          self.offer_year_bio2bac)

        self._create_context_exam_enrollment()
    def setUp(self):
        self.academic_year = AcademicYearFactory(
            year=datetime.date.today().year)
        self.academic_calendar = AcademicCalendarFactory.build(
            title="Submission of score encoding - 1",
            start_date=self.academic_year.start_date,
            end_date=self.academic_year.end_date,
            academic_year=self.academic_year,
            reference=academic_calendar_type.SCORES_EXAM_SUBMISSION)
        self.academic_calendar.save(functions=[])
        SessionExamCalendarFactory(academic_calendar=self.academic_calendar,
                                   number_session=number_session.ONE)
        # Offer year CHIM1BA
        self.offer_year = OfferYearFactory(acronym="CHIM1BA",
                                           academic_year=self.academic_year)
        self.learning_unit_year = LearningUnitYearFactory(
            acronym="LBIR1210", academic_year=self.academic_year)
        self._create_context_exam_enrollments(self.learning_unit_year,
                                              self.offer_year, 10, 3)
        self.learning_unit_year_2 = LearningUnitYearFactory(
            acronym="LBIR1211", academic_year=self.academic_year)
        self._create_context_exam_enrollments(self.learning_unit_year_2,
                                              self.offer_year, 5)

        # Offer year DIR2BA
        self.offer_year_2 = OfferYearFactory(acronym="DIR2BA",
                                             academic_year=self.academic_year)
        self._create_context_exam_enrollments(self.learning_unit_year,
                                              self.offer_year_2, 8, 5)
        self.program_manager = ProgramManagerFactory(
            offer_year=self.offer_year)
        ProgramManagerFactory(offer_year=self.offer_year_2,
                              person=self.program_manager.person)
        # Tutor [Tom Dupont] have an attribution to LBIR1210
        person = PersonFactory(last_name="Dupont", first_name="Thierry")
        self.tutor = TutorFactory(person=person)
        test_attribution.create_attribution(
            tutor=self.tutor,
            learning_unit_year=self.learning_unit_year,
            score_responsible=True)
Example #17
0
    def setUp(self):
        self.request_factory = RequestFactory()
        academic_year = _get_academic_year()
        academic_calendar = AcademicCalendarFactory.build(title="Submission of score encoding - 1",
                                                          start_date=academic_year.start_date,
                                                          end_date=academic_year.end_date,
                                                          academic_year=academic_year,
                                                          reference=academic_calendar_type.SCORES_EXAM_SUBMISSION)
        academic_calendar.save(functions=[])
        SessionExamCalendarFactory(academic_calendar=academic_calendar, number_session=number_session.ONE)

        self.learning_unit_year = LearningUnitYearFactory(academic_year=academic_year)
        self.offer_year = test_offer_year.create_offer_year('SINF1BA', 'Bachelor in informatica', academic_year)
        self.session_exam = test_session_exam.create_session_exam(number_session.ONE, self.learning_unit_year,
                                                                  self.offer_year)

        # Create enrollment related
        self.enrollments = []
        for index in range(0,2):
            offer_year = OfferYearFactory(academic_year=academic_year)
            OfferYearCalendarFactory(academic_calendar=academic_calendar, offer_year=offer_year)
            offer_enrollment = test_offer_enrollment.create_offer_enrollment(StudentFactory(), offer_year)
            learning_unit_enrollment = test_learning_unit_enrollment.create_learning_unit_enrollment(
                                                                       offer_enrollment=offer_enrollment,
                                                                       learning_unit_year=self.learning_unit_year)
            exam_enrollment = test_exam_enrollment.create_exam_enrollment(self.session_exam, learning_unit_enrollment)
            self.enrollments.append(exam_enrollment)

        self.tutor = TutorFactory()
        test_attribution.create_attribution(tutor=self.tutor, learning_unit_year=self.learning_unit_year)
        add_permission(self.tutor.person.user, "can_access_scoreencoding")

        offer_year = self.enrollments[0].learning_unit_enrollment.offer_enrollment.offer_year
        self.program_manager_1 = ProgramManagerFactory(offer_year=offer_year)
        add_permission(self.program_manager_1.person.user, "can_access_scoreencoding")

        offer_year = self.enrollments[1].learning_unit_enrollment.offer_enrollment.offer_year
        self.program_manager_2 = ProgramManagerFactory(offer_year=offer_year)
        add_permission(self.program_manager_2.person.user, "can_access_scoreencoding")
Example #18
0
    def setUp(self):
        self.academic_year_1 = AcademicYearFactory.build(
            start_date=today.replace(year=today.year + 1),
            end_date=today.replace(year=today.year + 2),
            year=today.year + 1)
        self.academic_year_2 = AcademicYearFactory.build(
            start_date=today.replace(year=today.year + 2),
            end_date=today.replace(year=today.year + 3),
            year=today.year + 2)
        self.academic_year_3 = AcademicYearFactory.build(
            start_date=today.replace(year=today.year + 3),
            end_date=today.replace(year=today.year + 4),
            year=today.year + 3)
        self.academic_year_4 = AcademicYearFactory.build(
            start_date=today.replace(year=today.year + 4),
            end_date=today.replace(year=today.year + 5),
            year=today.year + 4)
        self.academic_year_5 = AcademicYearFactory.build(
            start_date=today.replace(year=today.year + 5),
            end_date=today.replace(year=today.year + 6),
            year=today.year + 5)
        self.academic_year_6 = AcademicYearFactory.build(
            start_date=today.replace(year=today.year + 6),
            end_date=today.replace(year=today.year + 7),
            year=today.year + 6)
        self.current_academic_year = AcademicYearFactory.build(
            start_date=today,
            end_date=today.replace(year=today.year + 1),
            year=today.year)
        self.current_academic_year.save()
        super(AcademicYear, self.academic_year_1).save()
        super(AcademicYear, self.academic_year_2).save()
        super(AcademicYear, self.academic_year_3).save()
        super(AcademicYear, self.academic_year_4).save()
        super(AcademicYear, self.academic_year_5).save()
        super(AcademicYear, self.academic_year_6).save()

        self.current_academic_calendar = AcademicCalendarFactory.build(
            academic_year=self.current_academic_year)
        self.current_academic_calendar.save(functions=[])
        self.academic_calendar_1 = AcademicCalendarFactory.build(
            academic_year=self.academic_year_1)
        self.academic_calendar_1.save(functions=[])
        AcademicCalendarFactory.build(academic_year=self.academic_year_2).save(
            functions=[])
        AcademicCalendarFactory.build(academic_year=self.academic_year_3).save(
            functions=[])
        AcademicCalendarFactory.build(academic_year=self.academic_year_4).save(
            functions=[])
        AcademicCalendarFactory.build(academic_year=self.academic_year_5).save(
            functions=[])
        AcademicCalendarFactory.build(academic_year=self.academic_year_6).save(
            functions=[])
Example #19
0
 def setUp(self):
     self.academic_year = AcademicYearFactory()  # Current academic year
     self.academic_calendar = AcademicCalendarFactory.build(
         academic_year=self.academic_year)
     self.academic_calendar.save(functions=[])
Example #20
0
 def test_case_not_yet_persistent_parameter(self):
     academic_calendar = AcademicCalendarFactory.build(
         academic_year=self.academic_year)
     with self.assertRaises(ValueError):
         offer_year_calendar.save_from_academic_calendar(academic_calendar)