Exemplo n.º 1
0
    def setUpTestData(cls):
        current_academic_year = create_current_academic_year()
        previous_academic_year = AcademicYearFactory(year=current_academic_year.year-1)

        cls.current_entity_calendar = EntityCalendarFactory(academic_calendar__academic_year=current_academic_year,
                                                            academic_calendar__reference=SUMMARY_COURSE_SUBMISSION)
        previous_entity_calendar = EntityCalendarFactory(academic_calendar__academic_year=previous_academic_year,
                                                         academic_calendar__reference=SUMMARY_COURSE_SUBMISSION,
                                                         entity=cls.current_entity_calendar.entity)
Exemplo n.º 2
0
    def test_get_entity_calendar_with_parent_entity_calendar(self):
        an_entity_parent = EntityFactory()
        EntityVersionFactory(entity=an_entity_parent,
                             start_date=self.current_academic_year.start_date,
                             end_date=self.current_academic_year.end_date)
        an_entity_child = EntityFactory()
        an_child_entity_version = EntityVersionFactory(
            entity=an_entity_child,
            start_date=self.current_academic_year.start_date,
            end_date=self.current_academic_year.end_date,
            parent=an_entity_parent)

        an_academic_calendar = AcademicCalendarFactory(
            academic_year=self.current_academic_year,
            start_date=self.current_academic_year.start_date,
            end_date=self.current_academic_year.end_date,
            reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION)
        an_parent_entity_calendar = EntityCalendarFactory(
            entity=an_entity_parent,
            academic_calendar=an_academic_calendar,
            start_date=an_academic_calendar.start_date,
            end_date=an_academic_calendar.end_date)
        self.assertEqual(
            get_entity_calendar(an_child_entity_version,
                                self.current_academic_year),
            an_parent_entity_calendar)
Exemplo n.º 3
0
    def test_build_calendar_by_entity_have_entity_calendars_on_parent_structure(
            self):
        sst_date = {
            'start_date': timezone.now() - timezone.timedelta(days=5),
            'end_date': timezone.now() + timezone.timedelta(days=20)
        }
        EntityCalendarFactory(academic_calendar=self.ac_calendar,
                              entity=self.entity_sst.entity,
                              **sst_date)

        entity_calendar_computed = entity_calendar.build_calendar_by_entities(
            self.academic_year, SUMMARY_COURSE_SUBMISSION)
        default_date = {
            'start_date': self.ac_calendar.start_date,
            'end_date': self.ac_calendar.end_date
        }
        # Check on SSH node
        self.assertDictEqual(
            entity_calendar_computed[self.entity_ssh.entity.id], default_date)
        self.assertDictEqual(
            entity_calendar_computed[self.entity_lsm.entity.id], default_date)
        self.assertDictEqual(
            entity_calendar_computed[self.entity_clsm.entity.id], default_date)
        # Check on SST node
        self.assertDictEqual(
            entity_calendar_computed[self.entity_sst.entity.id],
            _convert_datetime_to_date(sst_date))
        self.assertDictEqual(
            entity_calendar_computed[self.entity_drt.entity.id],
            _convert_datetime_to_date(sst_date))
        self.assertDictEqual(
            entity_calendar_computed[self.entity_agro.entity.id],
            _convert_datetime_to_date(sst_date))
Exemplo n.º 4
0
 def _create_entity_calendar(self, an_entity):
     an_academic_calendar = AcademicCalendarFactory(academic_year=self.previous_academic_year,
                                                    start_date=self.previous_academic_year.start_date,
                                                    end_date=self.previous_academic_year.end_date,
                                                    reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION)
     EntityCalendarFactory(entity=an_entity, academic_calendar=an_academic_calendar,
                           start_date=an_academic_calendar.start_date,
                           end_date=an_academic_calendar.end_date)
Exemplo n.º 5
0
 def setUpTestData(cls):
     today = datetime.date.today()
     cls.current_academic_year = AcademicYearFactory(
         start_date=today,
         end_date=today.replace(year=today.year + 1),
         year=today.year)
     cls.parent_entity = EntityFactory()
     cls.child_entity = EntityFactory()
     cls.child_entity_bis = EntityFactory()
     cls.academic_calendar = AcademicCalendarFactory(
         academic_year=cls.current_academic_year,
         data_year=cls.current_academic_year,
         reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION)
     cls.parent_entity_version = EntityVersionFactory(
         start_date=cls.current_academic_year.start_date,
         end_date=cls.current_academic_year.end_date,
         entity=cls.parent_entity)
     cls.child_entity_version = EntityVersionFactory(
         start_date=cls.current_academic_year.start_date,
         end_date=cls.current_academic_year.end_date,
         entity=cls.child_entity,
         parent=cls.parent_entity)
     cls.child_entity_version_bis = EntityVersionFactory(
         start_date=cls.current_academic_year.start_date,
         end_date=cls.current_academic_year.end_date,
         entity=cls.child_entity_bis,
         parent=cls.parent_entity)
     cls.entity_version_without_entity_calendar = EntityVersionFactory(
         start_date=cls.current_academic_year.start_date,
         end_date=cls.current_academic_year.end_date)
     cls.parent_entity_calendar = EntityCalendarFactory(
         academic_calendar=cls.academic_calendar,
         entity=cls.parent_entity,
         start_date=timezone.now() - timezone.timedelta(days=40),
         end_date=timezone.now() + timezone.timedelta(days=20),
     )
     cls.child_entity_calendar_bis = EntityCalendarFactory(
         academic_calendar=cls.academic_calendar,
         entity=cls.child_entity_bis,
         start_date=cls.parent_entity_calendar.start_date -
         timezone.timedelta(days=5),
         end_date=cls.parent_entity_calendar.end_date -
         timezone.timedelta(days=2))
Exemplo n.º 6
0
    def test_find_interval_dates_for_entity_with_a_parent_entity_calendar(self):
        sst_date = {
            'start_date': timezone.now() - timezone.timedelta(days=5),
            'end_date': timezone.now() + timezone.timedelta(days=20)
        }
        EntityCalendarFactory(academic_calendar=self.ac_calendar, entity=self.entity_sst.entity, **sst_date)

        expected_date = _convert_datetime_to_date(sst_date)
        result = entity_calendar.find_interval_dates_for_entity(self.academic_year, SUMMARY_COURSE_SUBMISSION,
                                                                self.entity_drt.entity)
        self.assertDictEqual(result, expected_date)
Exemplo n.º 7
0
    def test_get_entity_calendar_no_calendar(self):
        an_entity = EntityFactory()
        an_entity_version = EntityVersionFactory(entity=an_entity,
                                                 start_date=self.current_academic_year.start_date,
                                                 end_date=self.current_academic_year.end_date)
        self.assertIsNone(get_entity_calendar(an_entity_version, self.current_academic_year))

        an_academic_calendar = AcademicCalendarFactory(academic_year=self.current_academic_year,
                                                       start_date=self.current_academic_year.start_date,
                                                       end_date=self.current_academic_year.end_date,
                                                       reference=academic_calendar_type.EXAM_ENROLLMENTS)
        EntityCalendarFactory(entity=an_entity,
                              academic_calendar=an_academic_calendar,
                              start_date=an_academic_calendar.start_date,
                              end_date=an_academic_calendar.end_date)
        self.assertIsNone(get_entity_calendar(an_entity_version, self.current_academic_year))