def setUp(self): current_academic_year = create_current_academic_year() an_organization = OrganizationFactory(type=organization_type.MAIN) learning_container_year = LearningContainerYearFactory( academic_year=current_academic_year, container_type=learning_container_year_types.COURSE, requirement_entity=EntityFactory()) self.learning_unit_year = LearningUnitYearFakerFactory( credits=5, subtype=learning_unit_year_subtypes.FULL, academic_year=current_academic_year, learning_container_year=learning_container_year, campus=CampusFactory(organization=an_organization, is_administration=True)) today = datetime.date.today() an_entity = EntityFactory(organization=an_organization) self.entity_version = EntityVersionFactory( entity=an_entity, entity_type=entity_type.SCHOOL, start_date=today, end_date=today.replace(year=today.year + 1)) self.learning_component_year_lecturing = LearningComponentYearFactory( type=learning_component_year_type.LECTURING, acronym="PM", learning_unit_year=self.learning_unit_year) self.learning_component_year_practical = LearningComponentYearFactory( type=learning_component_year_type.PRACTICAL_EXERCISES, acronym="PP", learning_unit_year=self.learning_unit_year)
def setUp(self): self.luy_full = LearningUnitYearFactory( academic_year=self.ay, subtype=learning_unit_year_subtypes.FULL, quadrimester=None) self.learning_component_year_full_lecturing = LearningComponentYearFactory( learning_unit_year=self.luy_full)
def setUpTestData(cls): cls.academic_year = AcademicYearFactory() cls.person = PersonFactory() cls.education_group_year_1 = EducationGroupYearFactory(title_english="", academic_year=cls.academic_year) cls.education_group_year_2 = EducationGroupYearFactory(title_english="", academic_year=cls.academic_year) cls.education_group_year_3 = EducationGroupYearFactory(title_english="", academic_year=cls.academic_year) cls.learning_unit_year_1 = LearningUnitYearFactory(specific_title_english="") cls.learning_unit_year_2 = LearningUnitYearFactory(specific_title_english="") cls.learning_component_year_1 = LearningComponentYearFactory( learning_unit_year=cls.learning_unit_year_1, hourly_volume_partial_q1=10, hourly_volume_partial_q2=10) cls.learning_component_year_2 = LearningComponentYearFactory( learning_unit_year=cls.learning_unit_year_1, hourly_volume_partial_q1=10, hourly_volume_partial_q2=10) cls.group_element_year_1 = GroupElementYearFactory(parent=cls.education_group_year_1, child_branch=cls.education_group_year_2) cls.group_element_year_2 = GroupElementYearFactory(parent=cls.education_group_year_2, child_branch=None, child_leaf=cls.learning_unit_year_1) cls.group_element_year_3 = GroupElementYearFactory(parent=cls.education_group_year_1, child_branch=cls.education_group_year_3) cls.group_element_year_4 = GroupElementYearFactory(parent=cls.education_group_year_3, child_branch=None, child_leaf=cls.learning_unit_year_2) cls.user = UserFactory() cls.person = PersonFactory(user=cls.user) cls.user.user_permissions.add(Permission.objects.get(codename="can_access_education_group")) cls.url = reverse( "learning_unit_utilization", args=[ cls.education_group_year_1.id, cls.learning_unit_year_1.id, ] )
def _link_components_and_learning_unit_year_to_container( l_container, acronym, volume_lecturing=None, volume_practical_exercices=None, subtype=learning_unit_year_subtypes.FULL): a_learning_unit_year = LearningUnitYearFactory( acronym=acronym, academic_year=l_container.academic_year, specific_title=l_container.common_title, subtype=subtype) if volume_lecturing: a_component = LearningComponentYearFactory( learning_container_year=l_container, type=learning_component_year_type.LECTURING, volume_declared_vacant=volume_lecturing) LearningUnitComponentFactory(learning_unit_year=a_learning_unit_year, learning_component_year=a_component, type=component_type.LECTURING) if volume_practical_exercices: a_component = LearningComponentYearFactory( learning_container_year=l_container, type=learning_component_year_type.PRACTICAL_EXERCISES, volume_declared_vacant=volume_practical_exercices) LearningUnitComponentFactory(learning_unit_year=a_learning_unit_year, learning_component_year=a_component, type=component_type.PRACTICAL_EXERCISES) return l_container
def _create_learning_unit_year_with_components(l_container, create_lecturing_component=True, create_pratical_component=True): language = LanguageFactory(code='EN', name='English') a_learning_unit_year = LearningUnitYearFactory( learning_container_year=l_container, acronym=l_container.acronym, academic_year=l_container.academic_year, status=True, language=language, campus=CampusFactory(name='MIT')) if create_lecturing_component: a_component = LearningComponentYearFactory( learning_container_year=l_container, type=learning_component_year_type.LECTURING, planned_classes=1) LearningUnitComponentFactory(learning_unit_year=a_learning_unit_year, learning_component_year=a_component) if create_pratical_component: a_component = LearningComponentYearFactory( learning_container_year=l_container, type=learning_component_year_type.PRACTICAL_EXERCISES, planned_classes=1) LearningUnitComponentFactory(learning_unit_year=a_learning_unit_year, learning_component_year=a_component) return a_learning_unit_year
def test_calculate_component_volume(self): an_attribution = { 'year': 2017, 'acronym': 'LAGRO1530', 'title': 'Chimie complexe', 'weight': '5.00', 'LECTURING': '22.5', 'PRACTICAL_EXERCISES': '5.0', 'function': 'HOLDER', 'start_year': 2015, 'end_year': 2020 } l_component_lecturing = LearningComponentYearFactory( type=learning_component_year_type.LECTURING) l_component_other = LearningComponentYearFactory(type=None) components_computed = { l_component_lecturing: { 'VOLUME_TOTAL': Decimal(15), 'PLANNED_CLASSES': 5 }, l_component_other: { 'VOLUME_TOTAL': Decimal(1), 'PLANNED_CLASSES': 1 } } attribution._calculate_component_volume(an_attribution, components_computed) self.assertEqual(an_attribution['lecturing_vol'], Decimal(75)) # VOLUME_TOTAL * PLANNED_CLASSES self.assertRaises(KeyError, lambda: an_attribution['practical_exercises_vol'])
def _create_learning_container_with_components( acronym, academic_year, volume_lecturing=None, volume_practical_exercices=None): l_container = LearningContainerYearFactory(acronym=acronym, academic_year=academic_year) a_learning_unit_year = LearningUnitYearFactory( acronym=acronym, academic_year=academic_year, specific_title=l_container.common_title, learning_container_year=l_container) if volume_lecturing: a_component = LearningComponentYearFactory( learning_container_year=l_container, type=learning_component_year_type.LECTURING, volume_declared_vacant=volume_lecturing) LearningUnitComponentFactory(learning_unit_year=a_learning_unit_year, learning_component_year=a_component, type=component_type.LECTURING) if volume_practical_exercices: a_component = LearningComponentYearFactory( learning_container_year=l_container, type=learning_component_year_type.PRACTICAL_EXERCISES, volume_declared_vacant=volume_practical_exercices) LearningUnitComponentFactory(learning_unit_year=a_learning_unit_year, learning_component_year=a_component, type=component_type.PRACTICAL_EXERCISES)
def setUpTestData(cls): cls.person = PersonFactory() cls.education_group_year_1 = EducationGroupYearFactory() cls.education_group_year_2 = EducationGroupYearFactory() cls.education_group_year_3 = EducationGroupYearFactory() cls.learning_unit_year_1 = LearningUnitYearFactory() cls.learning_unit_year_2 = LearningUnitYearFactory() cls.learning_component_year_1 = LearningComponentYearFactory( learning_container_year=cls.learning_unit_year_1.learning_container_year, hourly_volume_partial_q1=10, hourly_volume_partial_q2=10) cls.learning_component_year_2 = LearningComponentYearFactory( learning_container_year=cls.learning_unit_year_1.learning_container_year, hourly_volume_partial_q1=10, hourly_volume_partial_q2=10) cls.learning_unit_component_1 = LearningUnitComponentFactory( learning_component_year=cls.learning_component_year_1, learning_unit_year=cls.learning_unit_year_1) cls.learning_unit_component_2 = LearningUnitComponentFactory( learning_component_year=cls.learning_component_year_2, learning_unit_year=cls.learning_unit_year_1) cls.group_element_year_1 = GroupElementYearFactory(parent=cls.education_group_year_1, child_branch=cls.education_group_year_2) cls.group_element_year_2 = GroupElementYearFactory(parent=cls.education_group_year_2, child_branch=None, child_leaf=cls.learning_unit_year_1) cls.group_element_year_3 = GroupElementYearFactory(parent=cls.education_group_year_1, child_branch=cls.education_group_year_3) cls.group_element_year_4 = GroupElementYearFactory(parent=cls.education_group_year_3, child_branch=None, child_leaf=cls.learning_unit_year_2) cls.a_superuser = SuperUserFactory()
def setUp(self): self.current_academic_year = create_current_academic_year() self.person = PersonFactory() self.education_group_year_1 = EducationGroupYearFactory() self.education_group_year_2 = EducationGroupYearFactory() self.education_group_year_3 = EducationGroupYearFactory() self.learning_unit_year_1 = LearningUnitYearFactory() self.learning_component_year_1 = LearningComponentYearFactory( learning_container_year=self.learning_unit_year_1. learning_container_year, hourly_volume_partial_q1=10, hourly_volume_partial_q2=10) self.learning_component_year_2 = LearningComponentYearFactory( learning_container_year=self.learning_unit_year_1. learning_container_year, hourly_volume_partial_q1=10, hourly_volume_partial_q2=10) self.learning_unit_component_1 = LearningUnitComponentFactory( learning_component_year=self.learning_component_year_1, learning_unit_year=self.learning_unit_year_1) self.learning_unit_component_2 = LearningUnitComponentFactory( learning_component_year=self.learning_component_year_2, learning_unit_year=self.learning_unit_year_1) self.learning_unit_year_without_container = LearningUnitYearFactory( learning_container_year=None) self.group_element_year_1 = GroupElementYearFactory( parent=self.education_group_year_1, child_branch=self.education_group_year_2) self.group_element_year_2 = GroupElementYearFactory( parent=self.education_group_year_1, child_branch=None, child_leaf=self.learning_unit_year_1) self.group_element_year_3 = GroupElementYearFactory( parent=self.education_group_year_1, child_branch=self.education_group_year_3) self.group_element_year_without_container = GroupElementYearFactory( parent=self.education_group_year_1, child_branch=None, child_leaf=self.learning_unit_year_without_container) self.user = UserFactory() self.person = PersonFactory(user=self.user) self.user.user_permissions.add( Permission.objects.get(codename="can_access_education_group")) self.url = reverse("education_group_content", args=[ self.education_group_year_1.id, self.education_group_year_1.id, ]) self.client.force_login(self.user)
def _create_parent_with_components(self, learning_container_year): # Create learning unit year full luy_full = LearningUnitYearFactory( learning_container_year=learning_container_year, academic_year=learning_container_year.academic_year, acronym="LBIR1100", subtype=learning_unit_year_subtypes.FULL) ## Create component CM cm_component = LearningComponentYearFactory( acronym="CM", type=learning_component_year_type.LECTURING, learning_container_year=learning_container_year, planned_classes=1) LearningUnitComponentFactory(learning_unit_year=luy_full, learning_component_year=cm_component) ### Assign Volume cm_volume_parent = { entity_container_year_link_type.REQUIREMENT_ENTITY: { 'vol_tot': 50 }, entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_1: { 'vol_tot': 10 }, entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_2: { 'vol_tot': 20 }, } _assign_volume(learning_container_year, cm_component, cm_volume_parent) ## Create component TP tp_component = LearningComponentYearFactory( acronym="TP", type=learning_component_year_type.PRACTICAL_EXERCISES, learning_container_year=learning_container_year, planned_classes=1) LearningUnitComponentFactory(learning_unit_year=luy_full, learning_component_year=tp_component) ### Assign Volume tp_volume_parent = { entity_container_year_link_type.REQUIREMENT_ENTITY: { 'vol_tot': 30 }, entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_1: { 'vol_tot': 10 }, entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_2: { 'vol_tot': 10 }, } _assign_volume(learning_container_year, tp_component, tp_volume_parent) return luy_full
def test_update_or_create_entity_container_year_with_components_type_allocation(self): """In this test, we ensure that when we create an entity_container type allocation, we have NO entity_component created""" an_entity = EntityFactory() a_learning_container_year = LearningContainerYearFactory(academic_year=self.academic_year) LearningComponentYearFactory(acronym="CM", learning_container_year=a_learning_container_year) LearningComponentYearFactory(acronym="TP", learning_container_year=a_learning_container_year) link_type = entity_container_year_link_type.ALLOCATION_ENTITY update_or_create_entity_container_year_with_components(an_entity, a_learning_container_year, link_type) self.assertEqual(EntityContainerYear.objects.all().count(), 1) self.assertEqual(EntityComponentYear.objects.all().count(), 0)
def test_update_or_create_entity_container_year_with_components_type_requirement(self): """In this test, we ensure that when we create an entity_container type requirement, we have an entity_component created""" an_entity = EntityFactory() a_learning_container_year = LearningContainerYearFactory(academic_year=self.academic_year) LearningComponentYearFactory(acronym="CM", learning_container_year=a_learning_container_year) LearningComponentYearFactory(acronym="TP", learning_container_year=a_learning_container_year) link_type = random.choice(ENTITY_TYPES_VOLUME) update_or_create_entity_container_year_with_components(an_entity, a_learning_container_year, link_type) self.assertEqual(EntityContainerYear.objects.all().count(), 1) self.assertEqual(EntityComponentYear.objects.all().count(), 2)
def _create_learning_unit_year_with_components(academic_year, l_container, acronym, subtype): l_unit_year = LearningUnitYearFactory(academic_year=academic_year, learning_container_year=l_container, acronym=acronym, subtype=subtype) # Create component - CM - TP l_component_cm = LearningComponentYearFactory(learning_container_year=l_container, type=learning_component_year_type.LECTURING, acronym="CM") l_component_tp = LearningComponentYearFactory(learning_container_year=l_container, type=learning_component_year_type.PRACTICAL_EXERCISES, acronym="TP") # Create Link between UE and component LearningUnitComponentFactory(learning_unit_year=l_unit_year, learning_component_year=l_component_cm) LearningUnitComponentFactory(learning_unit_year=l_unit_year, learning_component_year=l_component_tp)
def setUpTestData(cls): cls.current_academic_year = create_current_academic_year() cls.education_group_year_1 = EducationGroupYearFactory( academic_year=cls.current_academic_year) cls.education_group_year_2 = EducationGroupYearFactory( academic_year=cls.current_academic_year) cls.education_group_year_3 = EducationGroupYearFactory( academic_year=cls.current_academic_year) cls.learning_unit_year_1 = LearningUnitYearFactory() cls.learning_component_year_1 = LearningComponentYearFactory( learning_unit_year=cls.learning_unit_year_1, hourly_volume_partial_q1=10, hourly_volume_partial_q2=10) cls.learning_component_year_2 = LearningComponentYearFactory( learning_unit_year=cls.learning_unit_year_1, hourly_volume_partial_q1=10, hourly_volume_partial_q2=10) cls.learning_unit_year_without_container = LearningUnitYearFactory( learning_container_year=None) cls.group_element_year_1 = GroupElementYearFactory( parent=cls.education_group_year_1, child_branch=cls.education_group_year_2) cls.group_element_year_2 = GroupElementYearFactory( parent=cls.education_group_year_1, child_branch=None, child_leaf=cls.learning_unit_year_1) cls.group_element_year_3 = GroupElementYearFactory( parent=cls.education_group_year_1, child_branch=cls.education_group_year_3) cls.group_element_year_without_container = GroupElementYearFactory( parent=cls.education_group_year_1, child_branch=None, child_leaf=cls.learning_unit_year_without_container) cls.user = UserFactory() cls.person = PersonWithPermissionsFactory('can_access_education_group', user=cls.user) cls.url = reverse("education_group_content", args=[ cls.education_group_year_1.id, cls.education_group_year_1.id, ])
def setUp(self): self.component_with_repartition = LearningComponentYearFactory( hourly_volume_total_annual=15.0, planned_classes=3, repartition_volume_requirement_entity=20.0, repartition_volume_additional_entity_1=10.0, repartition_volume_additional_entity_2=15.0, ) self.component_without_repartition = LearningComponentYearFactory( hourly_volume_total_annual=15.0, planned_classes=3, repartition_volume_requirement_entity=None, repartition_volume_additional_entity_1=None, repartition_volume_additional_entity_2=None, )
def setUpTestData(cls): cls.academic_year = AcademicYearFactory() cls.person = PersonFactory() cls.education_group_year_1 = EducationGroupYearFactory( title_english="", academic_year=cls.academic_year) cls.education_group_year_2 = EducationGroupYearFactory( title_english="", academic_year=cls.academic_year) cls.education_group_year_3 = EducationGroupYearFactory( title_english="", academic_year=cls.academic_year, acronym='ed3') cls.learning_unit_year_1 = LearningUnitYearFactory( specific_title_english="") cls.learning_unit_year_2 = LearningUnitYearFactory( specific_title_english="", acronym="luy2") cls.learning_component_year_1 = LearningComponentYearFactory( learning_unit_year=cls.learning_unit_year_1, hourly_volume_partial_q1=10, hourly_volume_partial_q2=10) cls.learning_component_year_2 = LearningComponentYearFactory( learning_unit_year=cls.learning_unit_year_1, hourly_volume_partial_q1=10, hourly_volume_partial_q2=10) cls.group_element_year_1 = GroupElementYearFactory( parent=cls.education_group_year_1, child_branch=cls.education_group_year_2, comment="commentaire", comment_english="english", block=1) cls.group_element_year_2 = GroupElementYearFactory( parent=cls.education_group_year_2, child_branch=None, child_leaf=cls.learning_unit_year_1, comment="commentaire", comment_english="english", block=6) cls.group_element_year_3 = GroupElementYearFactory( parent=cls.education_group_year_1, child_branch=cls.education_group_year_3, comment="commentaire", comment_english="english", block=1) cls.group_element_year_4 = GroupElementYearFactory( parent=cls.education_group_year_3, child_branch=None, child_leaf=cls.learning_unit_year_2, comment="commentaire", comment_english="english", block=123) cls.a_superuser = SuperUserFactory()
def test_get_requirement_entities_volumes(self): academic_year = AcademicYearFactory(year=2016) learning_container_year = LearningContainerYearFactory( academic_year=academic_year) learning_component_year = LearningComponentYearFactory( learning_container_year=learning_container_year) entity_types_list = [ entity_types.REQUIREMENT_ENTITY, entity_types.ADDITIONAL_REQUIREMENT_ENTITY_1, entity_types.ADDITIONAL_REQUIREMENT_ENTITY_2 ] entity_containers_year = [ EntityContainerYearFactory( type=entity_types_list[x], learning_container_year=learning_container_year) for x in range(3) ] components = [ EntityComponentYearFactory( entity_container_year=entity_containers_year[x], learning_component_year=learning_component_year, hourly_volume_total=x + 5) for x in range(3) ] wanted_response = { "REQUIREMENT_ENTITY": 5, "ADDITIONAL_REQUIREMENT_ENTITY_1": 6, "ADDITIONAL_REQUIREMENT_ENTITY_2": 7, } self.assertDictEqual( learning_unit_year_with_context._get_requirement_entities_volumes( components), wanted_response)
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) ]
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
def test_learning_unit_usage_two_usages(self): learning_container_yr = LearningContainerYearFactory( academic_year=self.current_academic_year, acronym='LBIOL') learning_unit_yr_1 = LearningUnitYearFactory( academic_year=self.current_academic_year, acronym='LBIOLA', quadrimester='Q1', learning_container_year=learning_container_yr) learning_unit_yr_2 = LearningUnitYearFactory( academic_year=self.current_academic_year, acronym='LBIOLB', learning_container_year=learning_container_yr) learning_component_yr = LearningComponentYearFactory( learning_container_year=learning_container_yr) LearningUnitComponentFactory( learning_unit_year=learning_unit_yr_1, learning_component_year=learning_component_yr) LearningUnitComponentFactory( learning_unit_year=learning_unit_yr_2, learning_component_year=learning_component_yr) self.assertEqual( learning_unit_business._learning_unit_usage(learning_component_yr), 'LBIOLA (Q1), LBIOLB (?)')
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
def test_dl_component_tooltip(self): lcy = LearningComponentYearFactory( hourly_volume_partial_q1=OTHER_VOLUME) context = { 'components_initial_data': { 'components': [ { 'learning_component_year': { 'id': lcy.id, 'hourly_volume_partial_q1': lcy.hourly_volume_partial_q1 }, 'volumes': { 'VOLUME_Q1': OTHER_VOLUME } }, ] } } expected_html = "<dl><dd data-toggle=tooltip title='{} : {}' class='{}' id='id_volume_q1'><p style='' " \ "title=''>{}</p></dd></dl>". \ format(LABEL_VALUE_BEFORE_PROPOSAL, OTHER_VOLUME, CSS_PROPOSAL_VALUE, VOLUME) self.assertEqual( dl_component_tooltip({'differences': context}, "VOLUME_Q1", value=VOLUME, id=lcy.id), expected_html)
def setUpTestData(cls): cls.language_fr = LanguageFactory(code="FR") cls.language_en = LanguageFactory(code="EN") cls.user = UserFactory() flag, created = Flag.objects.get_or_create(name='learning_achievement_update') flag.users.add(cls.user) cls.person = PersonWithPermissionsFactory("can_access_learningunit", "can_create_learningunit", user=cls.user) cls.person_entity = PersonEntityFactory(person=cls.person) EntityVersionFactory(entity=cls.person_entity.entity) cls.academic_years = AcademicYearFactory.produce_in_future(quantity=5) cls.max_la_number = 2*len(cls.academic_years) cls.learning_unit = LearningUnitFactory(start_year=cls.academic_years[0], end_year=cls.academic_years[-1]) cls.learning_container = LearningContainerFactory() cls.learning_unit_years = [LearningUnitYearFactory( academic_year=academic_year, subtype=learning_unit_year_subtypes.FULL, learning_container_year=LearningContainerYearFactory( academic_year=academic_year, learning_container=cls.learning_container, requirement_entity=cls.person_entity.entity ), learning_unit=cls.learning_unit, acronym="TEST0000" ) for academic_year in cls.academic_years] cls.learning_component_years = [LearningComponentYearFactory( learning_unit_year=luy, ) for luy in cls.learning_unit_years]
def setUp(self): self.person = PersonFactory(first_name="John", last_name="Doe") self.tutor = TutorFactory(person=self.person) self.attribution_new = AttributionNewFactory(tutor=self.tutor, function=function.PROFESSOR) self.attribution_new_without_attribution_charge = AttributionNewFactory(tutor=self.tutor, function=function.PROFESSOR) self.learning_component_year_lecturing = LearningComponentYearFactory(type=component_type.LECTURING) self.learning_component_year_practical = LearningComponentYearFactory(type=component_type.PRACTICAL_EXERCISES) self.attribution_charge_new_lecturing = \ AttributionChargeNewFactory(attribution=self.attribution_new, learning_component_year=self.learning_component_year_lecturing, allocation_charge=10) self.attribution_charge_new_practical = \ AttributionChargeNewFactory(attribution=self.attribution_new, learning_component_year=self.learning_component_year_practical, allocation_charge=20)
def _setup_learning_component_year(learning_unit_year, component_type): component = LearningComponentYearFactory(learning_container_year=learning_unit_year.learning_container_year, type=component_type) LearningUnitComponentFactory(learning_unit_year=learning_unit_year, learning_component_year=component) return component
def test_update_volumes_data(self): volumes = { learning_component_year_type.LECTURING: VOLUMES_INITIALIZED, learning_component_year_type.PRACTICAL_EXERCISES: VOLUMES_INITIALIZED } lecturing_data = { 'PLANNED_CLASSES': 1, 'VOLUME_Q1': 10, 'VOLUME_TOTAL': 50, 'VOLUME_Q2': 40 } compo = { 'learning_component_year': LearningComponentYearFactory( learning_container_year=self.learning_container_luy1, type=learning_component_year_type.LECTURING), 'volumes': lecturing_data } volumes_updated = _update_volumes_data(compo, volumes) self.assertCountEqual( volumes_updated.get(learning_component_year_type.LECTURING), lecturing_data) self.assertCountEqual( volumes_updated.get( learning_component_year_type.PRACTICAL_EXERCISES), VOLUMES_INITIALIZED)
def setUp(self): today = datetime.date.today() self.current_academic_year = AcademicYearFactory( start_date=today, end_date=today.replace(year=today.year + 1), year=today.year) self.learning_container_yr = LearningContainerYearFactory( academic_year=self.current_academic_year) self.organization = OrganizationFactory(type=organization_type.MAIN) self.country = CountryFactory() self.entity = EntityFactory(country=self.country, organization=self.organization) self.entity_container_yr = EntityContainerYearFactory( learning_container_year=self.learning_container_yr, type=entity_container_year_link_type.REQUIREMENT_ENTITY, entity=self.entity) self.learning_component_yr = LearningComponentYearFactory( learning_container_year=self.learning_container_yr, hourly_volume_partial=-1, planned_classes=1) self.entity_component_yr = EntityComponentYearFactory( learning_component_year=self.learning_component_yr, entity_container_year=self.entity_container_yr, hourly_volume_total=None) self.entity_components_yr = [ self.entity_component_yr, ]
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
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 _create_learning_unit_year_with_components(academic_year, l_container, acronym, subtype): l_unit_year = LearningUnitYearFactory(academic_year=academic_year, learning_container_year=l_container, acronym=acronym, subtype=subtype) # Create component - CM - TP LearningComponentYearFactory(learning_unit_year=l_unit_year, type=learning_component_year_type.LECTURING, acronym="PM") LearningComponentYearFactory( learning_unit_year=l_unit_year, type=learning_component_year_type.PRACTICAL_EXERCISES, acronym="PP") return l_unit_year