示例#1
0
    def create_learning_unit_years_and_dependencies(self):
        l1 = LearningUnitFactory()

        learning_unit_years = []
        for year in range(4):
            ac_year = AcademicYearFactory(year=2000 + year)
            l_containeryear = LearningContainerYearFactory(
                academic_year=ac_year)
            EntityContainerYearFactory(
                learning_container_year=l_containeryear,
                entity=self.entity_version.entity,
                type=entity_container_year_link_type.REQUIREMENT_ENTITY)
            learning_unit_year = LearningUnitYearFactory(
                learning_unit=l1,
                academic_year=ac_year,
                learning_container_year=l_containeryear)
            learning_unit_years.append(learning_unit_year)

        learning_unit_years[1].subtype = learning_unit_year_subtypes.FULL
        learning_unit_years[1].save()
        lcomponent = LearningComponentYearFactory()
        LearningClassYearFactory(learning_component_year=lcomponent)
        LearningClassYearFactory(learning_component_year=lcomponent)
        LearningUnitComponentFactory(learning_unit_year=learning_unit_years[1],
                                     learning_component_year=lcomponent)
        return learning_unit_years
示例#2
0
    def create_learning_unit_years_and_dependencies(self):
        acronym = "LDROI1004"
        l1 = LearningUnitFactory(
            start_year=settings.YEAR_LIMIT_LUE_MODIFICATION)

        learning_unit_years = []
        for year in range(4):
            ac_year = AcademicYearFactory(
                year=settings.YEAR_LIMIT_LUE_MODIFICATION + year)
            l_containeryear = LearningContainerYearFactory(
                academic_year=ac_year)
            EntityContainerYearFactory(
                learning_container_year=l_containeryear,
                entity=self.entity_version.entity,
                type=entity_container_year_link_type.REQUIREMENT_ENTITY)
            learning_unit_year = LearningUnitYearFactory(
                acronym=acronym,
                learning_unit=l1,
                academic_year=ac_year,
                learning_container_year=l_containeryear)
            learning_unit_years.append(learning_unit_year)

        learning_unit_years[1].subtype = learning_unit_year_subtypes.FULL
        learning_unit_years[1].save()
        lcomponent = LearningComponentYearFactory()
        LearningClassYearFactory(learning_component_year=lcomponent)
        LearningClassYearFactory(learning_component_year=lcomponent)
        return learning_unit_years
示例#3
0
    def create_learning_unit_years_and_dependencies(self):
        academic_year = create_editable_academic_year()
        acronym = "LDROI1004"
        l1 = LearningUnitFactory(start_year=academic_year.year)

        learning_unit_years = []
        for year in range(4):
            ac_year = AcademicYearFactory(year=academic_year.year + year)
            l_containeryear = LearningContainerYearFactory(
                academic_year=ac_year,
                requirement_entity=self.entity_version.entity,
            )
            learning_unit_year = LearningUnitYearFactory(
                acronym=acronym,
                learning_unit=l1,
                academic_year=ac_year,
                learning_container_year=l_containeryear)
            learning_unit_years.append(learning_unit_year)

        learning_unit_years[1].subtype = learning_unit_year_subtypes.FULL
        learning_unit_years[1].save()
        lcomponent = LearningComponentYearFactory()
        LearningClassYearFactory(learning_component_year=lcomponent)
        LearningClassYearFactory(learning_component_year=lcomponent)
        return learning_unit_years
示例#4
0
    def test_delete_learning_component_class(self):
        # Composant annualisé est associé à son composant et à son conteneur annualisé
        learning_component_year = LearningComponentYearFactory(acronym="/C",
                                                               comment="TEST")
        learning_container_year = learning_component_year.learning_unit_year.learning_container_year

        number_classes = 10
        for x in range(number_classes):
            LearningClassYearFactory(learning_component_year=learning_component_year)

        learning_unit_year = learning_component_year.learning_unit_year
        learning_unit_year.learning_unit.start_year = 1900
        learning_unit_year.subtype = learning_unit_year_subtypes.PARTIM
        learning_unit_year.save()

        msg = deletion.delete_from_given_learning_unit_year(learning_unit_year)

        msg_success = _("Learning unit %(acronym)s (%(academic_year)s) successfuly deleted.") % {
            'acronym': learning_unit_year.acronym,
            'academic_year': learning_unit_year.academic_year,
        }
        self.assertEqual(msg_success, msg.pop())

        self.assertEqual(LearningClassYear.objects.all().count(), 0)

        self.assertEqual(len(msg), number_classes)
        with self.assertRaises(ObjectDoesNotExist):
            LearningComponentYear.objects.get(id=learning_component_year.id)

        for classe in learning_component_year.learningclassyear_set.all():
            with self.assertRaises(ObjectDoesNotExist):
                LearningClassYear.objects.get(id=classe.id)

        # The learning_unit_container won't be deleted because the learning_unit_year is a partim
        self.assertEqual(learning_container_year, LearningContainerYear.objects.get(id=learning_container_year.id))
 def setUp(self):
     self.academic_year = AcademicYearFactory(year=2016)
     self.learning_unit_years = [
         LearningUnitYearFactory(academic_year=self.academic_year)
         for x in range(2)
     ]
     self.learning_container_years = [
         LearningContainerYearFactory(academic_year=self.academic_year)
         for x in range(2)
     ]
     self.learning_component_years = [
         LearningComponentYearFactory(
             learning_container_year=self.learning_container_years[x])
         for x in range(2)
     ]
     self.learning_unit_components = [
         LearningUnitComponentFactory(
             learning_unit_year=self.learning_unit_years[x],
             learning_component_year=self.learning_component_years[x])
         for x in range(2)
     ]
     self.learning_class_years = [
         LearningClassYearFactory(
             learning_component_year=self.learning_component_years[x])
         for x in range(2)
     ]
示例#6
0
    def test_get_components_with_classes(self):
        l_container = LearningContainerFactory()
        l_container_year = LearningContainerYearFactory(
            academic_year=self.current_academic_year,
            title="LC-98998",
            learning_container=l_container)
        l_component_year = LearningComponentYearFactory(
            learning_container_year=l_container_year)
        LearningClassYearFactory(learning_component_year=l_component_year)
        LearningClassYearFactory(learning_component_year=l_component_year)
        learning_unit_year = LearningUnitYearFactory(
            academic_year=self.current_academic_year,
            learning_container_year=l_container_year)

        components = learning_unit_business.get_same_container_year_components(
            learning_unit_year, True)
        self.assertEqual(len(components), 1)
        self.assertEqual(len(components[0]['learning_component_year'].classes),
                         2)
    def test_delete_learning_unit_component_class(self):
        # Composant annualisé est associé à son composant et à son conteneur annualisé
        learning_component_year = LearningComponentYearFactory(
            title="Cours magistral", acronym="/C", comment="TEST")
        learning_container_year = learning_component_year.learning_container_year

        number_classes = 10
        for x in range(number_classes):
            LearningClassYearFactory(
                learning_component_year=learning_component_year)

        # Association du conteneur et de son composant dont les années académiques diffèrent l'une de l'autre
        learning_unit_component = LearningUnitComponentFactory(
            learning_component_year=learning_component_year)

        learning_unit_year = learning_unit_component.learning_unit_year
        learning_unit_year.learning_unit.start_year = 1900
        learning_unit_year.subtype = learning_unit_year_subtypes.PARTIM
        learning_unit_year.save()

        msg = learning_unit_deletion.delete_from_given_learning_unit_year(
            learning_unit_year)

        msg_success = _(
            "%(subtype)s %(acronym)s has been deleted for the year %(year)s")
        self.assertEqual(
            msg_success % {
                'subtype': _('The partim'),
                'acronym': learning_unit_year.acronym,
                'year': learning_unit_year.academic_year
            }, msg.pop())

        self.assertEqual(LearningClassYear.objects.all().count(), 0)

        self.assertEqual(len(msg), number_classes)
        with self.assertRaises(ObjectDoesNotExist):
            LearningUnitComponent.objects.get(id=learning_component_year.id)

        with self.assertRaises(ObjectDoesNotExist):
            LearningUnitComponent.objects.get(id=learning_unit_component.id)

        # The learning_unit_container won't be deleted because the learning_unit_year is a partim
        self.assertEqual(
            learning_container_year,
            LearningContainerYear.objects.get(id=learning_container_year.id))
示例#8
0
    def test_class_save(self):
        learning_unit_yr = LearningUnitYearFactory(
            academic_year=self.current_academic_year,
            learning_container_year=self.learning_container_yr)
        learning_unit_compnt = LearningUnitComponentFactory(
            learning_unit_year=learning_unit_yr,
            learning_component_year=self.learning_component_yr)
        learning_class_yr = LearningClassYearFactory(
            learning_component_year=self.learning_component_yr)

        response = self.client.post('{}?{}&{}'.format(
            reverse('learning_class_year_edit', args=[learning_unit_yr.id]),
            'learning_component_year_id={}'.format(
                self.learning_component_yr.id),
            'learning_class_year_id={}'.format(learning_class_yr.id)),
                                    data={"used_by": "on"})
        self.learning_component_yr.refresh_from_db()
        self.assertEqual(response.status_code, 302)
示例#9
0
    def test_class_save_create_link(self):
        learning_unit_yr = LearningUnitYearFactory(
            academic_year=self.current_academic_year,
            learning_container_year=self.learning_container_yr)
        learning_unit_compnt = LearningUnitComponentFactory(
            learning_unit_year=learning_unit_yr,
            learning_component_year=self.learning_component_yr)
        learning_class_yr = LearningClassYearFactory(
            learning_component_year=self.learning_component_yr)

        response = self.client.post('{}?{}&{}'.format(
            reverse('learning_class_year_edit', args=[learning_unit_yr.id]),
            'learning_component_year_id={}'.format(
                self.learning_component_yr.id),
            'learning_class_year_id={}'.format(learning_class_yr.id)),
                                    data={"used_by": "on"})

        self.assertTrue(
            learning_unit_component_class.search(learning_unit_compnt,
                                                 learning_class_yr).exists())
示例#10
0
    def test_compare_learning_component_year(self):
        acronym_used_twice = 'PM1'
        acronym_used_once = 'PM2'

        l_comp_yr_current = LearningComponentYearFactory(
            acronym=acronym_used_twice, planned_classes=1)
        LearningClassYearFactory(learning_component_year=l_comp_yr_current)
        l_comp_yr_previous = LearningComponentYearFactory(
            acronym=acronym_used_twice, planned_classes=1)
        l_comp_yr_next = LearningComponentYearFactory(
            acronym=acronym_used_once, planned_classes=1)

        data = compare_learning_component_year(l_comp_yr_current,
                                               l_comp_yr_previous,
                                               l_comp_yr_next)
        self.assertEqual(data.get('acronym'), [
            l_comp_yr_previous.acronym, l_comp_yr_current.acronym,
            l_comp_yr_next.acronym
        ])
        self.assertEqual(data.get('real_classes'), [
            l_comp_yr_previous.real_classes, l_comp_yr_current.real_classes,
            l_comp_yr_next.real_classes
        ])
示例#11
0
    def test_class_save_delete_link(self):
        learning_unit_yr = LearningUnitYearFactory(
            academic_year=self.current_academic_year,
            learning_container_year=self.learning_container_yr)
        learning_unit_compnt = LearningUnitComponentFactory(
            learning_unit_year=learning_unit_yr,
            learning_component_year=self.learning_component_yr)
        learning_class_yr = LearningClassYearFactory(
            learning_component_year=self.learning_component_yr)
        a_link = LearningUnitComponentClassFactory(
            learning_unit_component=learning_unit_compnt,
            learning_class_year=learning_class_yr)

        response = self.client.post('{}?{}&{}'.format(
            reverse('learning_class_year_edit', args=[learning_unit_yr.id]),
            'learning_component_year_id={}'.format(
                self.learning_component_yr.id),
            'learning_class_year_id={}'.format(learning_class_yr.id)),
                                    data={})

        self.assertRaises(
            ObjectDoesNotExist,
            learning_unit_component_class.LearningUnitComponentClass.objects.
            filter(pk=a_link.id).first())
示例#12
0
    def test_learning_unit_usage_by_class_with_complete_LU(self):
        academic_year = AcademicYearFactory(year=2016)
        learning_container_yr = LearningContainerYearFactory(
            academic_year=academic_year, acronym='LBIOL')

        learning_unit_yr_1 = LearningUnitYearFactory(
            academic_year=academic_year,
            acronym='LBIOL',
            learning_container_year=learning_container_yr)

        learning_component_yr = LearningComponentYearFactory(
            learning_container_year=learning_container_yr)

        learning_unit_component = LearningUnitComponentFactory(
            learning_unit_year=learning_unit_yr_1,
            learning_component_year=learning_component_yr)
        learning_class_year = LearningClassYearFactory(
            learning_component_year=learning_component_yr)
        LearningUnitComponentClassFactory(
            learning_unit_component=learning_unit_component,
            learning_class_year=learning_class_year)
        self.assertEqual(
            learning_unit_business._learning_unit_usage_by_class(
                learning_class_year), 'LBIOL')
示例#13
0
def _setup_classes(learning_component_year, number_classes=5):
    for i in range(number_classes):
        LearningClassYearFactory(learning_component_year=learning_component_year)