Example #1
0
    def test_application_session_period_opened(self):
        test_academic_year.create_academic_year_with_year(CURRENT_YEAR)
        next_academic_year = test_academic_year.create_academic_year_with_year(
            NEXT_YEAR)

        test_academic_calendar.create_academic_calendar(
            next_academic_year, permission.TEACHING_CHARGE_APPLICATION, now,
            now)

        self.assertEqual(permission.is_online_application_opened(self.a_user),
                         True)
Example #2
0
 def test_application_session_period_closed(self):
     current_academic_year = test_academic_year.create_academic_year_with_year(
         CURRENT_YEAR)
     test_academic_year.create_academic_year_with_year(NEXT_YEAR)
     two_weeks_ago = datetime.datetime.today() - datetime.timedelta(15)
     test_academic_calendar.create_academic_calendar(
         current_academic_year,
         academic_calendar_type.TEACHING_CHARGE_APPLICATION, two_weeks_ago,
         two_weeks_ago + datetime.timedelta(1))
     self.assertEqual(permission.is_online_application_opened(self.a_user),
                      False)
Example #3
0
 def test_application_session_period_closed(self):
     test_academic_year.create_academic_year_with_year(CURRENT_YEAR)
     next_academic_year = test_academic_year.create_academic_year_with_year(
         NEXT_YEAR)
     two_weeks_ago = datetime.datetime.now() - datetime.timedelta(15)
     test_academic_calendar.create_academic_calendar(
         next_academic_year, permission.TEACHING_CHARGE_APPLICATION,
         datetime.datetime(two_weeks_ago.year, two_weeks_ago.month,
                           two_weeks_ago.day),
         datetime.datetime(two_weeks_ago.year, two_weeks_ago.month,
                           two_weeks_ago.day + 1))
     self.assertEqual(permission.is_online_application_opened(self.a_user),
                      False)
    def test_with_end_date_inferior_to_offer_year_calendar_end_date(self):
        an_academic_calendar = create_academic_calendar(
            an_academic_year=self.an_academic_year)
        an_offer_year = OfferYearFactory(academic_year=self.an_academic_year)
        an_offer_year_calendar = OfferYearCalendarFactory(
            academic_calendar=an_academic_calendar,
            offer_year=an_offer_year,
            customized=True)

        form = AcademicCalendarForm(data={
            "academic_year":
            self.an_academic_year.pk,
            "title":
            "New title",
            "start_date":
            an_academic_calendar.start_date,
            "end_date":
            an_offer_year_calendar.end_date - datetime.timedelta(days=2)
        },
                                    instance=an_academic_calendar)
        self.assertFalse(form.is_valid())
        date_format = str(_('date_format'))
        self.assertEqual(
            form.errors['end_date'], "%s." %
            (_('academic_calendar_offer_year_calendar_end_date_error') %
             (an_academic_calendar.title,
              an_offer_year_calendar.end_date.strftime(date_format),
              an_academic_calendar.title,
              an_offer_year_calendar.offer_year.acronym)))
Example #5
0
    def setUp(self):
        today = datetime.datetime.today()
        half_year = datetime.timedelta(days=180)
        twenty_days = datetime.timedelta(days=20)

        an_academic_year = AcademicYearFakerFactory(year=today.year,
                                                    start_date=today -
                                                    half_year,
                                                    end_date=today + half_year)
        a_learning_unit_year = LearningUnitYearFakerFactory(
            academic_year=an_academic_year, acronym=LEARNING_UNIT_ACRONYM)

        tutor = TutorFactory()

        an_academic_calendar = create_academic_calendar(
            an_academic_year,
            start_date=today - twenty_days,
            end_date=today + twenty_days,
            reference=academic_calendar_type.SCORES_EXAM_SUBMISSION)
        SessionExamCalendarFactory(number_session=number_session.ONE,
                                   academic_calendar=an_academic_calendar)
        AttributionFactory(learning_unit_year=a_learning_unit_year,
                           tutor=tutor)
        a_session_exam = SessionExamFactory(
            number_session=number_session.ONE,
            learning_unit_year=a_learning_unit_year)

        student_1 = StudentFactory(registration_id=REGISTRATION_ID_1)
        student_2 = StudentFactory(registration_id=REGISTRATION_ID_2)

        an_offer_year = OfferYearFactory(academic_year=an_academic_year,
                                         acronym=OFFER_ACRONYM)
        offer_enrollment_1 = OfferEnrollmentFactory(offer_year=an_offer_year,
                                                    student=student_1)
        offer_enrollment_2 = OfferEnrollmentFactory(offer_year=an_offer_year,
                                                    student=student_2)

        learning_unit_enrollment_1 = LearningUnitEnrollmentFactory(
            learning_unit_year=a_learning_unit_year,
            offer_enrollment=offer_enrollment_1)
        learning_unit_enrollment_2 = LearningUnitEnrollmentFactory(
            learning_unit_year=a_learning_unit_year,
            offer_enrollment=offer_enrollment_2)

        ExamEnrollmentFactory(
            session_exam=a_session_exam,
            learning_unit_enrollment=learning_unit_enrollment_1)
        ExamEnrollmentFactory(
            session_exam=a_session_exam,
            learning_unit_enrollment=learning_unit_enrollment_2)

        user = tutor.person.user
        self.client = Client()
        self.client.force_login(user=user)
        self.url = reverse(
            'upload_encoding',
            kwargs={'learning_unit_year_id': a_learning_unit_year.id})
Example #6
0
def create_offer_year_calendar(offer_yr, academic_year):
    academic_calendar = test_academic_calendar.create_academic_calendar(
        academic_year)
    return OfferYearCalendarFactory(offer_year=offer_yr,
                                    academic_calendar=academic_calendar)