def test_cannot_faculty_manager_modify_end_date_no_container(self): luy = LearningUnitYearFactory(academic_year=self.academic_yr, learning_container_year=None) self.assertFalse( perms._is_learning_unit_year_in_state_to_be_modified( luy, self.person_fac, False))
def test_is_external(self): luy = LearningUnitYearFactory() ExternalLearningUnitYearFactory(learning_unit_year=luy) self.assertTrue(luy.is_external())
def setUp(self): self.learning_unit_year = LearningUnitYearFactory() self.requirement_entity = EntityContainerYearFactory( type=entity_container_year_link_type.REQUIREMENT_ENTITY, learning_container_year=self.learning_unit_year.learning_container_year )
def test_add_blank_queryset(self): luy = LearningUnitYearFactory() result = add_blank(LearningUnitYear.objects.all().values_list( 'id', 'acronym')) self.assertEqual(result, [(None, '---------'), (luy.id, luy.acronym)])
def test_ccomplete_title_when_no_learning_container_year(self): specific_title = 'part 1: Vertebrate' luy = LearningUnitYearFactory(specific_title=specific_title, learning_container_year=None) self.assertEqual(luy.complete_title, specific_title)
def test_cannot_faculty_manager_modify_end_date_no_container(self): luy = LearningUnitYearFactory(academic_year=self.academic_yr, learning_container_year=None) self.assertFalse(luy.can_update_by_faculty_manager())
def test_wrong_learning_unit_full_instance_args(self): wrong_lu_full = LearningUnitYearFactory() with self.assertRaises(AttributeError): _instanciate_form(learning_unit_full=wrong_lu_full, academic_year=self.current_academic_year)
def setUp(self): self.current_academic_year = create_current_academic_year() self.child_leaf = LearningUnitYearFactory(academic_year=self.current_academic_year)
def test_case_different_objects_instances(self): with self.assertRaises(AttributeError): group_element_year._raise_if_incorrect_instance( [EducationGroupYearFactory(), LearningUnitYearFactory()])
def setUpTestData(cls): now = datetime.datetime.now() cls.academic_years = AcademicYearFactory.produce(number_past=5, number_future=5) cls.academic_year = cls.academic_years[5] cls.old_academic_year = cls.academic_years[4] cls.next_academic_year = cls.academic_years[5] cls.previous_academic_year = cls.academic_years[4] AcademicCalendarFactory( academic_year=cls.previous_academic_year, start_date=now - datetime.timedelta(days=5), end_date=now + datetime.timedelta(days=15), reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION) cls.requirement_entity_version = EntityVersionFactory( entity__organization__type=organization_type.MAIN, start_date=now, end_date=datetime.datetime(now.year + 1, 9, 15), entity_type=entity_type.INSTITUTE) cls.url = reverse('learning_units_summary') cls.faculty_person = FacultyManagerFactory( 'can_access_learningunit', 'can_edit_learningunit_pedagogy') PersonEntityFactory(person=cls.faculty_person, entity=cls.requirement_entity_version.entity) # Generate data for XLS export cls.learning_unit_year_with_mandatory_teaching_materials = LearningUnitYearFactory( acronym="LBIR1100", academic_year=cls.academic_year, learning_container_year__academic_year=cls.academic_year, learning_container_year__acronym="LBIR1100", learning_container_year__requirement_entity=cls. requirement_entity_version.entity) TeachingMaterialFactory( learning_unit_year=cls. learning_unit_year_with_mandatory_teaching_materials, title="Magic wand", mandatory=True, ) TeachingMaterialFactory( learning_unit_year=cls. learning_unit_year_with_mandatory_teaching_materials, title="Broomsticks", mandatory=False, ) cls.learning_unit_year_without_mandatory_teaching_materials = LearningUnitYearFactory( acronym="LDROI1600", academic_year=cls.academic_year, learning_container_year__academic_year=cls.academic_year, learning_container_year__acronym="LDROI1600", learning_container_year__requirement_entity=cls. requirement_entity_version.entity) TeachingMaterialFactory( learning_unit_year=cls. learning_unit_year_without_mandatory_teaching_materials, title="cauldron", mandatory=False, )
def test_with_filters_case_childs_with_different_academic_years(self): child_leaf_other_ac_year = LearningUnitYearFactory( academic_year=AcademicYearFactory(year=self.current_academic_year.year - 1) ) with self.assertRaises(AttributeError): group_element_year._find_related_formations([self.child_leaf, child_leaf_other_ac_year], self.filters)
def test_get_data_part2(self): learning_container_luy = LearningContainerYearFactory( academic_year=self.current_academic_year) luy = LearningUnitYearFactory( academic_year=self.current_academic_year, learning_container_year=learning_container_luy, periodicity=learning_unit_year_periodicity.ANNUAL, status=True, language=None, ) component_lecturing = LearningComponentYearFactory( learning_container_year=learning_container_luy, type=learning_component_year_type.LECTURING, hourly_volume_total_annual=15, hourly_volume_partial_q1=10, hourly_volume_partial_q2=5, planned_classes=1) component_practical = LearningComponentYearFactory( learning_container_year=learning_container_luy, type=learning_component_year_type.PRACTICAL_EXERCISES, hourly_volume_total_annual=15, hourly_volume_partial_q1=10, hourly_volume_partial_q2=5, planned_classes=1) LearningUnitComponentFactory( learning_unit_year=luy, learning_component_year=component_lecturing) LearningUnitComponentFactory( learning_unit_year=luy, learning_component_year=component_practical) a_tutor = TutorFactory() an_attribution = AttributionNewFactory(tutor=a_tutor, start_year=2017) attribution_charge_new_lecturing = AttributionChargeNewFactory( learning_component_year=component_lecturing, attribution=an_attribution, allocation_charge=15.0) attribution_charge_new_practical = AttributionChargeNewFactory( learning_component_year=component_practical, attribution=an_attribution, allocation_charge=5.0) luy.attribution_charge_news = attribution_charge_new.find_attribution_charge_new_by_learning_unit_year( luy) expected_common = [ xls_build.translate(luy.periodicity), xls_build.translate(luy.status), component_lecturing.hourly_volume_total_annual, component_lecturing.hourly_volume_partial_q1, component_lecturing.hourly_volume_partial_q2, component_lecturing.planned_classes, component_practical.hourly_volume_total_annual, component_practical.hourly_volume_partial_q1, component_practical.hourly_volume_partial_q2, component_practical.planned_classes, xls_build.translate(luy.quadrimester), xls_build.translate(luy.session), "", '' ] self.assertEqual(_get_data_part2(luy, False), expected_common) self.assertEqual( _get_data_part2(luy, True), expected_attribution_data(attribution_charge_new_lecturing, attribution_charge_new_practical, expected_common, luy))
def test_get_absolute_credits_empty(self): luy = LearningUnitYearFactory(credits=None) GroupElementYearFactory(child_branch=None, child_leaf=luy) self.assertEqual(_get_absolute_credits(luy), '')
def setUpTestData(cls): current_year = get_current_year() cls.academic_years = [AcademicYearFactory(year=i) for i in range(current_year, current_year + 7)] cls.luys = [LearningUnitYearFactory() for _ in range(10)]
def setUpTestData(cls): today = datetime.date.today() an_academic_year = create_current_academic_year() cls.requirement_entity = EntityVersionFactory( entity_type=entity_type.SCHOOL, start_date=today.replace(year=1900), entity__organization__type=organization_type.MAIN, ) cls.allocation_entity = EntityVersionFactory( start_date=today.replace(year=1900), entity__organization__type=organization_type.MAIN, ) cls.additional_entity_1 = EntityVersionFactory( start_date=today.replace(year=1900), entity__organization__type=organization_type.MAIN, ) cls.additional_entity_2 = EntityVersionFactory( start_date=today.replace(year=1900), entity__organization__type=organization_type.MAIN, ) learning_container_year = LearningContainerYearFactory( academic_year=an_academic_year, container_type=learning_container_year_types.COURSE, type_declaration_vacant=vacant_declaration_type.DO_NOT_ASSIGN, requirement_entity=cls.requirement_entity.entity, allocation_entity=cls.allocation_entity.entity, additional_entity_1=cls.additional_entity_1.entity, additional_entity_2=cls.additional_entity_2.entity, ) cls.learning_unit_year = LearningUnitYearFactory( learning_container_year=learning_container_year, acronym="LOSIS4512", academic_year=an_academic_year, subtype=learning_unit_year_subtypes.FULL, attribution_procedure=attribution_procedure.INTERNAL_TEAM, credits=15, campus=CampusFactory(organization=OrganizationFactory( type=organization_type.MAIN)), internship_subtype=None, ) cls.partim_learning_unit = LearningUnitYearFactory( learning_container_year=learning_container_year, acronym="LOSIS4512A", academic_year=an_academic_year, subtype=learning_unit_year_subtypes.PARTIM, credits=10, campus=CampusFactory(organization=OrganizationFactory( type=organization_type.MAIN))) cls.person = PersonEntityFactory( entity=cls.requirement_entity.entity).person cls.user = cls.person.user cls.user.user_permissions.add( Permission.objects.get(codename="can_edit_learningunit"), Permission.objects.get(codename="can_access_learningunit")) cls.url = reverse(update_learning_unit, args=[cls.learning_unit_year.id])
def setUp(self): self.tutor = TutorFactory() self.academic_year = AcademicYearFactory(year=timezone.now().year) self.learning_unit_year = LearningUnitYearFactory(acronym="LDROI1004", title="Juridic law courses", academic_year=self.academic_year)
def setUp(self): self.learning_unit_yr = LearningUnitYearFactory( specific_title=TITLE, status=True, professional_integration=True, quadrimester=quadrimesters.Q1)
def setUpTestData(cls): cls.luy_to_find = LearningUnitYearFactory(acronym='CYN', specific_title='Drop dead cynical') cls.egy_to_find = EducationGroupYearFactory(acronym='RAV', title='The Ravenlord') cls.user = SuperUserFactory()
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(2017) 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( title="Submission of score encoding - 1", academic_year=academic_year, reference=academic_calendar_type.SCORES_EXAM_SUBMISSION) academic_calendar.save() 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() # Mock academic_year / session_exam_calendar in order to be decouple from system time self.mock_academic_year( current_academic_year=academic_year, starting_academic_year=academic_year, ) self.mock_session_exam_calendar( current_session_exam=self.session_exam_calendar)
def setUp(self): self.person_1 = test_person.create_person("person_1", last_name="test", email="*****@*****.**") self.person_2 = test_person.create_person("person_2", last_name="test", email="*****@*****.**") self.persons = [self.person_1, self.person_2] self.person_3 = PersonWithPermissionsFactory( "can_receive_emails_about_automatic_postponement") self.academic_year = test_academic_year.create_academic_year() test_academic_year.create_academic_year(year=self.academic_year.year - 1) self.learning_unit_year = LearningUnitYearFactory( acronym="TEST", specific_title="Cours de test", academic_year=self.academic_year) self.offer_year = test_offer_year.create_offer_year( "SINF2MA", "Master en Sciences Informatique", self.academic_year) self.exam_enrollment_1 = test_exam_enrollment.create_exam_enrollment_with_student( 1, "64641200", self.offer_year, self.learning_unit_year) self.exam_enrollment_2 = test_exam_enrollment.create_exam_enrollment_with_student( 2, "60601200", self.offer_year, self.learning_unit_year) self.msg_list = [ 'The partim TEST_A has been deleted for the year ' + str(self.academic_year.year), 'The partim TEST_B has been deleted for the year ' + str(self.academic_year.year), 'The class TEST_C has been deleted for the year ' + str(self.academic_year.year), 'The class TEST_A_C1 has been deleted for the year ' + str(self.academic_year.year), 'The class TEST_A_C2 has been deleted for the year ' + str(self.academic_year.year), 'The class TEST_B_C1 has been deleted for the year ' + str(self.academic_year.year), 'The class TEST_B_C2 has been deleted for the year ' + str(self.academic_year.year), 'The learning unit TEST has been successfully deleted for all years' ] self.egys_to_postpone = EducationGroupYear.objects.all() self.egys_already_existing = EducationGroupYear.objects.all() self.egys_ending_this_year = EducationGroupYear.objects.all() self.luys_to_postpone = LearningUnitYear.objects.all() self.luys_already_existing = LearningUnitYear.objects.all() self.luys_ending_this_year = LearningUnitYear.objects.all() self.ending_on_max_adjournment = LearningUnitYear.objects.all() self.statistics_data = { 'max_academic_year_to_postpone': self.academic_year, 'to_duplicate': self.luys_to_postpone, 'already_duplicated': self.luys_already_existing, 'to_ignore': self.luys_ending_this_year, 'ending_on_max_academic_year': self.ending_on_max_adjournment } add_message_template_html() add_message_template_txt()
def test_get_data_part2(self): learning_container_luy = LearningContainerYearFactory( academic_year=self.current_academic_year) luy = LearningUnitYearFactory( academic_year=self.current_academic_year, learning_container_year=learning_container_luy, periodicity=learning_unit_year_periodicity.ANNUAL, status=True, language=None, ) component_lecturing = LearningComponentYearFactory( learning_container_year=learning_container_luy, type=learning_component_year_type.LECTURING, hourly_volume_total_annual=15, hourly_volume_partial_q1=10, hourly_volume_partial_q2=5, planned_classes=1) component_practical = LearningComponentYearFactory( learning_container_year=learning_container_luy, type=learning_component_year_type.PRACTICAL_EXERCISES, hourly_volume_total_annual=15, hourly_volume_partial_q1=10, hourly_volume_partial_q2=5, planned_classes=1) LearningUnitComponentFactory( learning_unit_year=luy, learning_component_year=component_lecturing) LearningUnitComponentFactory( learning_unit_year=luy, learning_component_year=component_practical) a_tutor = TutorFactory() an_attribution = AttributionNewFactory(tutor=a_tutor, start_year=2017) attribution_charge_new_lecturing = AttributionChargeNewFactory( learning_component_year=component_lecturing, attribution=an_attribution, allocation_charge=15.0) attribution_charge_new_practical = AttributionChargeNewFactory( learning_component_year=component_practical, attribution=an_attribution, allocation_charge=5.0) # Simulate annotate luy = annotate_qs(LearningUnitYear.objects.filter(pk=luy.pk)).first() luy.entity_requirement = EntityVersionFactory() luy.attribution_charge_news = attribution_charge_new.find_attribution_charge_new_by_learning_unit_year_as_dict( luy) expected_common = [ str(_(luy.periodicity.title())), str(_('yes')) if luy.status else str(_('no')), component_lecturing.hourly_volume_total_annual, component_lecturing.hourly_volume_partial_q1, component_lecturing.hourly_volume_partial_q2, component_lecturing.planned_classes, component_practical.hourly_volume_total_annual, component_practical.hourly_volume_partial_q1, component_practical.hourly_volume_partial_q2, component_practical.planned_classes, luy.get_quadrimester_display() or '', luy.get_session_display() or '', "", ] self.assertEqual(_get_data_part2(luy, False), expected_common) self.assertEqual( _get_data_part2(luy, True), expected_attribution_data(attribution_charge_new_lecturing, attribution_charge_new_practical, expected_common, luy))
def test_subtype_is_full(self): learn_unit_year = LearningUnitYearFactory(subtype=learning_unit_year_subtypes.FULL) form = _instanciate_form(learn_unit_year.academic_year, learning_unit_instance=learn_unit_year.learning_unit) self.assertEqual(form.subtype, learning_unit_year_subtypes.FULL)
def test_get_learning_unit_parent_without_parent(self): lunit_container_year = LearningContainerYearFactory(academic_year=self.academic_year, acronym='LBIR1230') luy_parent = LearningUnitYearFactory(academic_year=self.academic_year, acronym='LBIR1230', learning_container_year=lunit_container_year, subtype=learning_unit_year_subtypes.FULL) self.assertIsNone(luy_parent.parent)
def setUp(self): self.learning_unit_year_2009 = LearningUnitYearFactory( academic_year=AcademicYearFactory(year=2009), acronym='LDROI1200') self.learning_unit_year_2017 = LearningUnitYearFactory( academic_year=AcademicYearFactory(year=2017), acronym='LDROI1200')
def test_complete_title_property_case_common_and_specific_title_are_set(self): specific_title = 'part 1: Vertebrate' common_title = 'Zoology' luy = LearningUnitYearFactory(specific_title=specific_title, learning_container_year__common_title=common_title) self.assertEqual(luy.complete_title, '{} - {}'.format(common_title, specific_title))
def test_when_learning_unit_is_not_external(self): learning_unit_year = LearningUnitYearFactory() person = PersonFactory() self.assertTrue( perms.is_external_learning_unit_cograduation( learning_unit_year, person, False))
def test_is_not_external(self): luy = LearningUnitYearFactory() self.assertFalse(luy.is_external())
def test_check_related_partims_deletion(self): l_container_year = LearningContainerYearFactory() LearningUnitYearFactory(acronym="LBIR1212", learning_container_year=l_container_year, academic_year=self.academic_year, subtype=learning_unit_year_subtypes.FULL, learning_unit=self.learning_unit) msg = deletion._check_related_partims_deletion(l_container_year) self.assertEqual(len(msg.values()), 0) l_unit_2 = LearningUnitYearFactory( acronym="LBIR1212", learning_container_year=l_container_year, academic_year=self.academic_year, subtype=learning_unit_year_subtypes.PARTIM) LearningUnitEnrollmentFactory(learning_unit_year=l_unit_2) LearningUnitEnrollmentFactory(learning_unit_year=l_unit_2) LearningUnitEnrollmentFactory(learning_unit_year=l_unit_2) group_1 = GroupElementYearFactory(child_branch=None, child_leaf=l_unit_2) group_2 = GroupElementYearFactory(child_branch=None, child_leaf=l_unit_2) component = LearningUnitComponentFactory(learning_unit_year=l_unit_2) attribution_1 = AttributionNewFactory( learning_container_year=l_unit_2.learning_container_year) attribution_2 = AttributionNewFactory( learning_container_year=l_unit_2.learning_container_year) AttributionChargeNewFactory( learning_component_year=component.learning_component_year, attribution=attribution_1) AttributionChargeNewFactory( learning_component_year=component.learning_component_year, attribution=attribution_1) AttributionChargeNewFactory( learning_component_year=component.learning_component_year, attribution=attribution_2) msg = deletion._check_related_partims_deletion(l_container_year) msg = list(msg.values()) self.assertEqual(len(msg), 5) self.assertIn( _("There is %(count)d enrollments in %(subtype)s %(acronym)s for the year %(year)s" ) % { 'subtype': _('The partim'), 'acronym': l_unit_2.acronym, 'year': l_unit_2.academic_year, 'count': 3 }, msg) msg_delete_tutor = _( "%(subtype)s %(acronym)s is assigned to %(tutor)s for the year %(year)s" ) self.assertIn( msg_delete_tutor % { 'subtype': _('The partim'), 'acronym': l_unit_2.acronym, 'year': l_unit_2.academic_year, 'tutor': attribution_1.tutor }, msg) self.assertIn( msg_delete_tutor % { 'subtype': _('The partim'), 'acronym': l_unit_2.acronym, 'year': l_unit_2.academic_year, 'tutor': attribution_2.tutor }, msg) msg_delete_offer_type = _('lu_included_in_group') self.assertIn( msg_delete_offer_type % { 'subtype': _('The partim'), 'acronym': l_unit_2.acronym, 'group': group_1.parent.partial_acronym, 'year': l_unit_2.academic_year }, msg) self.assertIn( msg_delete_offer_type % { 'subtype': _('The partim'), 'acronym': l_unit_2.acronym, 'group': group_2.parent.partial_acronym, 'year': l_unit_2.academic_year }, msg)
def setUpTestData(cls): cls.learning_unit_years = [LearningUnitYearFactory() for _ in range(5)] cls.person = PersonFactory() cls.person.user.user_permissions.add( Permission.objects.get(codename="can_access_learningunit")) cls.url = reverse("learning_units_borrowed_course")
def setUp(self): self.parent = TrainingFactory(academic_year=self.academic_year) self.child_leaf = LearningUnitYearFactory() self.child_branch = MiniTrainingFactory( academic_year=self.academic_year)