def test_get_partims_related(self): from base.views.learning_unit import _get_partims_related current_year = datetime.date.today().year academic_year = AcademicYearFactory(year=current_year) l_container_year = LearningContainerYearFactory( academic_year=academic_year) l_container_year_2 = LearningContainerYearFactory( academic_year=academic_year) # Create learning unit year attached to learning container year learning_unit_year_1 = LearningUnitYearFactory( academic_year=academic_year, learning_container_year=l_container_year, subtype=learning_unit_year_subtypes.FULL) LearningUnitYearFactory(academic_year=academic_year, learning_container_year=l_container_year, subtype=learning_unit_year_subtypes.PARTIM) LearningUnitYearFactory(academic_year=academic_year, learning_container_year=l_container_year, subtype=learning_unit_year_subtypes.PARTIM) learning_unit_year_2 = LearningUnitYearFactory( academic_year=academic_year, learning_container_year=l_container_year_2, subtype=learning_unit_year_subtypes.FULL) LearningUnitYearFactory(academic_year=academic_year, learning_container_year=None) all_partims_container_year_1 = _get_partims_related( learning_unit_year_1) self.assertEqual(len(all_partims_container_year_1), 2) all_partims_container_year_2 = _get_partims_related( learning_unit_year_2) self.assertEqual(len(all_partims_container_year_2), 0)
def setUp(self): self.academic_year = AcademicYearFactory(year=2017) external_id = tutor_application_osis.LEARNING_CONTAINER_YEAR_PREFIX_EXTERNAL_ID + '35654987_2017' self.lbir1200 = LearningContainerYearFactory( academic_year=self.academic_year, acronym="LBIR1200", external_id=external_id) self.lagro2630 = LearningContainerYearFactory( academic_year=self.academic_year, acronym="LAGRO2630") self.bio = LearningContainerYearFactory( academic_year=self.academic_year, acronym="BIO5213") # Creation Person/Tutor Group.objects.create(name="tutors") person = PersonFactory(global_id="98363454") external_id = tutor_application_osis.TUTOR_PREFIX_EXTERNAL_ID + '2089590559' self.tutor = TutorFactory(external_id=external_id, person=person) # Create two tutor applications applications = [ _get_application_example(self.lbir1200, '30.5', '40.5'), _get_application_example(self.lagro2630, '12.5', '10.5'), _get_application_example(self.bio, '10.5', '9.5') ] self.attribution_new = AttributionNewFactory( global_id=person.global_id, applications=applications)
def setUpTestData(cls): cls.person = PersonFactory() cls.user = cls.person.user cls.tutor = TutorFactory(person=cls.person) cls.current_ac_year = create_current_academic_year() ac_year_in_future = GenerateAcademicYear( start_year=cls.current_ac_year.year + 1, end_year=cls.current_ac_year.year + 5) cls.academic_calendar = AcademicCalendarFactory( academic_year=cls.current_ac_year, reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION) # Create multiple attribution in different academic years for ac_year in [cls.current_ac_year ] + ac_year_in_future.academic_years: learning_container_year = LearningContainerYearFactory( academic_year=ac_year) learning_unit_year = LearningUnitYearFactory( summary_locked=False, academic_year=ac_year, learning_container_year=learning_container_year) AttributionFactory( tutor=cls.tutor, summary_responsible=True, learning_unit_year=learning_unit_year, ) cls.url = reverse(list_my_attributions_summary_editable)
def setUpTestData(cls): cls.academic_year = create_current_academic_year() cls.learning_unit = LearningUnitFactory(start_year__year=1900) cls.l_container_year = LearningContainerYearFactory(acronym="LBIR1212", academic_year=cls.academic_year) cls.user = UserFactory()
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 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 test_delete_cms_data(self): """In this test, we will ensure that CMS data linked to the learning unit year is correctly deleted""" learning_container_year = LearningContainerYearFactory(academic_year=self.academic_year) learning_unit_year_to_delete = LearningUnitYearFactory(learning_container_year=learning_container_year, subtype=learning_unit_year_subtypes.FULL, academic_year=learning_container_year.academic_year) # Create CMS data - TAB Specification cms_specification_label = TextLabelFactory(entity=entity_name.LEARNING_UNIT_YEAR, label=CMS_LABEL_SPECIFICATIONS[0]) TranslatedTextFactory(entity=entity_name.LEARNING_UNIT_YEAR, reference=learning_unit_year_to_delete.pk, text_label=cms_specification_label, text='Specification of learning unit year') # Create CMS data - TAB Pedagogy cms_pedagogy_label = TextLabelFactory(entity=entity_name.LEARNING_UNIT_YEAR, label=CMS_LABEL_PEDAGOGY[0]) TranslatedTextFactory(entity=entity_name.LEARNING_UNIT_YEAR, reference=learning_unit_year_to_delete.pk, text_label=cms_pedagogy_label, text='Pedagogy of learning unit year') # Create CMS data - TAB Summary cms_summary_label = TextLabelFactory(entity=entity_name.LEARNING_UNIT_YEAR, label=CMS_LABEL_SUMMARY[0]) TranslatedTextFactory(entity=entity_name.LEARNING_UNIT_YEAR, reference=learning_unit_year_to_delete.pk, text_label=cms_summary_label, text='Summary of learning unit year') # Before delete, we should have 3 data in CMS self.assertEqual(3, TranslatedText.objects.all().count()) deletion._delete_cms_data(learning_unit_year_to_delete) # After deletion, we should have no data in CMS self.assertFalse(TranslatedText.objects.all().count())
def setUp(self): today = datetime.date.today() self.academic_yr = AcademicYearFactory( start_date=today, end_date=today.replace(year=today.year + 1), year=today.year) self.academic_yr_1 = AcademicYearFactory.build( start_date=today.replace(year=today.year + 1), end_date=today.replace(year=today.year + 2), year=today.year + 1) super(AcademicYear, self.academic_yr_1).save() self.academic_year_6 = AcademicYearFactory.build( start_date=today.replace(year=today.year + 6), end_date=today.replace(year=today.year + 7), year=today.year + 6) super(AcademicYear, self.academic_year_6).save() self.lunit_container_yr = LearningContainerYearFactory( academic_year=self.academic_yr) lu = LearningUnitFactory(end_year=self.academic_yr.year) self.luy = LearningUnitYearFactory( academic_year=self.academic_yr, learning_container_year=self.lunit_container_yr, subtype=FULL, learning_unit=lu)
def _create_list_containers(self, number_of_containers): list_lu_container_year = [ LearningContainerYearFactory(acronym="LC%d" % container, academic_year=self.academic_yr) for container in range(number_of_containers) ] return list_lu_container_year
def setUp(self): self.person = PersonFactory() self.tutor = TutorFactory(person=self.person) self.learning_container_year = LearningContainerYearFactory() self.attribution_new = AttributionNewFactory(learning_container_year=self.learning_container_year, start_year=2018, end_year=2020, tutor=self.tutor, score_responsible=True)
def test_check_learning_unit_year_deletion(self): l_container_year = LearningContainerYearFactory( acronym="LBIR1212", academic_year=self.academic_year) l_unit_1 = LearningUnitYearFactory( acronym="LBIR1212", learning_container_year=l_container_year, academic_year=self.academic_year, subtype=learning_unit_year_subtypes.FULL) msg = deletion.check_learning_unit_year_deletion(l_unit_1) msg = list(msg.values()) self.assertEqual(msg, []) l_unit_2 = LearningUnitYearFactory( acronym="LBIR1212A", learning_container_year=l_container_year, academic_year=self.academic_year, subtype=learning_unit_year_subtypes.PARTIM) LearningUnitYearFactory(acronym="LBIR1212B", learning_container_year=l_container_year, academic_year=self.academic_year, subtype=learning_unit_year_subtypes.PARTIM) LearningUnitEnrollmentFactory(learning_unit_year=l_unit_1) LearningUnitEnrollmentFactory(learning_unit_year=l_unit_2) msg = deletion.check_learning_unit_year_deletion(l_unit_1) msg = list(msg.values()) self.assertEqual(len(msg), 2)
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 setUpTestData(cls): cls.full_learning_unit_year = LearningUnitYearFactory(subtype=learning_unit_year_subtypes.FULL) cls.partim_learning_unit_year = LearningUnitYearFactory( subtype=learning_unit_year_subtypes.PARTIM, learning_container_year=cls.full_learning_unit_year.learning_container_year) cls.learning_container_year = LearningContainerYearFactory()
def setUp(self): Group.objects.get_or_create(name='tutors') self.person = PersonFactory() self.tutor = TutorFactory(person=self.person) attribution_permission = Permission.objects.get( codename='can_access_attribution') self.person.user.user_permissions.add(attribution_permission) today = datetime.datetime.today() self.academic_year = AcademicYearFactory( year=today.year, start_date=today - datetime.timedelta(days=5), end_date=today + datetime.timedelta(days=5)) self.learning_unit_year = LearningUnitYearFactory( academic_year=self.academic_year) self.learning_unit_year.learning_container_year = LearningContainerYearFactory( academic_year=self.learning_unit_year.academic_year, in_charge=True) self.learning_unit_year.save() self.attribution = AttributionFactory( function=function.CO_HOLDER, learning_unit_year=self.learning_unit_year, tutor=self.tutor, external_id=ATTRIBUTION_EXTERNAL_ID) self.url = reverse('attribution_home') self.client.force_login(self.person.user)
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 test_find_latest_requirment_entity(self): work_on_year = 2016 # Change version in order to have multiple version during the year self.entity_versions[work_on_year].end_date = datetime.datetime( work_on_year, 3, 30) self.entity_versions[work_on_year].save() lastest_entity_version = EntityVersionFactory( entity=self.entity, parent=None, acronym="Entity V_{}_3".format(work_on_year), start_date=datetime.datetime(work_on_year, 8, 1), end_date=None) EntityVersionFactory(entity=self.entity, parent=None, acronym="Entity V_{}_2".format(work_on_year), start_date=datetime.datetime(work_on_year, 4, 1), end_date=datetime.datetime(work_on_year, 7, 30)) l_container_year = LearningContainerYearFactory( academic_year=self.academic_years[work_on_year]) # Create a link between entity and container # Requirement entity EntityContainerYearFactory( entity=self.entity, learning_container_year=l_container_year, type=entity_container_year_link_type.REQUIREMENT_ENTITY) # Find requirement entity requirement_entity_found = entity_container_year.find_requirement_entity( learning_container_year=l_container_year) self.assertEqual(lastest_entity_version, requirement_entity_found)
def test_find_entities_no_values(self): l_container_year = LearningContainerYearFactory( academic_year=self.academic_years[2015], requirement_entity=None) # No link between an entity/learning_container_year, so no result no_entity = base.models.learning_container_year.find_last_entity_version_grouped_by_linktypes( learning_container_year=l_container_year) self.assertFalse(no_entity)
def test_delete_partim_from_full(self): l_container_year = LearningContainerYearFactory( academic_year=self.academic_year) l_unit_year = LearningUnitYearFactory( subtype=learning_unit_year_subtypes.FULL, learning_container_year=l_container_year, learning_unit=LearningUnitFactory(start_year=1900), academic_year=l_container_year.academic_year) l_unit_partim_1 = LearningUnitYearFactory( subtype=learning_unit_year_subtypes.PARTIM, learning_container_year=l_container_year, learning_unit=LearningUnitFactory(start_year=1900), academic_year=l_container_year.academic_year) l_unit_partim_2 = LearningUnitYearFactory( subtype=learning_unit_year_subtypes.PARTIM, learning_container_year=l_container_year, learning_unit=LearningUnitFactory(start_year=1900), academic_year=l_container_year.academic_year) deletion.delete_from_given_learning_unit_year(l_unit_year) with self.assertRaises(ObjectDoesNotExist): LearningUnitYear.objects.get(id=l_unit_partim_1.id) with self.assertRaises(ObjectDoesNotExist): LearningUnitYear.objects.get(id=l_unit_partim_2.id)
def test_find_entities_grouped_by_linktype(self): requirement_entity = EntityFactory() allocation_entity = EntityFactory() additional_requirement_entity_1 = EntityFactory() additional_requirement_entity_2 = EntityFactory() a_learning_container_year = LearningContainerYearFactory( requirement_entity=requirement_entity, allocation_entity=allocation_entity, additional_entity_1=additional_requirement_entity_1, additional_entity_2=additional_requirement_entity_2, ) entities_by_linktype = a_learning_container_year.get_map_entity_by_type( ) expected_result = { entity_container_year_link_type.REQUIREMENT_ENTITY: requirement_entity, entity_container_year_link_type.ALLOCATION_ENTITY: allocation_entity, entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_1: additional_requirement_entity_1, entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_2: additional_requirement_entity_2 } self.assertDictEqual(entities_by_linktype, expected_result)
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 test_consistency_report_error_displayed(self): next_academic_year = AcademicYearFactory( year=self.learning_unit_year.academic_year.year + 1) next_learning_container_year = LearningContainerYearFactory( academic_year=next_academic_year, container_type=learning_container_year_types.COURSE) LearningUnitYearFactory( learning_container_year=next_learning_container_year, learning_unit=self.learning_unit_year.learning_unit, acronym="LOSIS4512", academic_year=next_academic_year, subtype=learning_unit_year_subtypes.FULL, credits=26) form_data = self._get_valid_form_data() response = self.client.post(self.url, data=form_data) expected_redirection = reverse("learning_unit", args=[self.learning_unit_year.id]) self.assertRedirects(response, expected_redirection, fetch_redirect_response=False) messages = [ str(message) for message in get_messages(response.wsgi_request) ] self.assertIn( _('The learning unit has been updated until %(year)s.') % {'year': self.learning_unit_year.academic_year}, list(messages))
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 setUp(self): self.academic_year = create_current_academic_year() self.next_academic_year = AcademicYearFactory( year=self.academic_year.year + 1) self.learning_container_year = LearningContainerYearFactory( academic_year=self.academic_year, common_title='common title', ) self.learning_unit_year = _create_learning_unit_year_with_components( self.learning_container_year, create_lecturing_component=True, create_pratical_component=True) an_entity = EntityFactory() self.entity_version = EntityVersionFactory(entity=an_entity, parent=None, end_date=None, acronym="DRT") self.allocation_entity = _create_entity_container_with_entity_components( self.learning_unit_year, entity_container_year_link_type.ALLOCATION_ENTITY, an_entity) self.requirement_entity = _create_entity_container_with_entity_components( self.learning_unit_year, entity_container_year_link_type.REQUIREMENT_ENTITY, an_entity, repartition_lecturing=30, repartition_practical_exercises=10) self.add_requirement_entity_1 = _create_entity_container_with_entity_components( self.learning_unit_year, entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_1, an_entity, repartition_lecturing=10, repartition_practical_exercises=5)
def test_with_post_but_webservice_unavailable(self, mock_fetch): today = datetime.datetime.today() an_academic_year = AcademicYearFactory( year=today.year, start_date=today - datetime.timedelta(days=5), end_date=today + datetime.timedelta(days=5)) learning_container_year = LearningContainerYearFactory( academic_year=an_academic_year) a_learning_unit_year = LearningUnitYearFactory( academic_year=an_academic_year, learning_container_year=learning_container_year) AttributionFactory(learning_unit_year=a_learning_unit_year, tutor=self.tutor) key = '{}{}'.format(LEARNING_UNIT_ACRONYM_ID, a_learning_unit_year.acronym) response = self.client.post(self.url, data={key: ""}) self.assertTrue(mock_fetch.called) self.assertEqual(response.status_code, OK) self.assertTemplateUsed(response, 'list/students_exam.html') self.assertEqual(response.context['person'], self.tutor.person) self.assertEqual(response.context['my_learning_units'], [a_learning_unit_year]) self.assertEqual(response.context['msg_error'], _('No data found'))
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 test_cannot_delete_learning_unit_year_with_administrative_manager_role(self): manager = AdministrativeManagerFactory() entity_version = EntityVersionFactory(entity_type=entity_type.FACULTY, acronym="SST", start_date=datetime.date(year=1990, month=1, day=1), end_date=None) PersonEntityFactory(person=manager, entity=entity_version.entity, with_child=True) # Creation UE learning_unit = LearningUnitFactory() l_containeryear = LearningContainerYearFactory(academic_year=self.academic_year, container_type=learning_container_year_types.COURSE, requirement_entity=entity_version.entity) learning_unit_year = LearningUnitYearFactory(learning_unit=learning_unit, academic_year=self.academic_year, learning_container_year=l_containeryear, subtype=learning_unit_year_subtypes.FULL) # Cannot remove FULL COURSE self.assertFalse( base.business.learning_units.perms.is_eligible_to_delete_learning_unit_year( learning_unit_year, manager ) ) # Can remove PARTIM COURSE learning_unit_year.subtype = learning_unit_year_subtypes.PARTIM learning_unit_year.save() self.assertFalse( base.business.learning_units.perms.is_eligible_to_delete_learning_unit_year( learning_unit_year, manager ) )
def _setup_learning_container_year(self, learning_container): self.requirement_entity_container_year = self.entities[0] self.allocation_entity_container_year = self.entities[1] self.additionnal_1_entity_container_year = self.entities[2] self.addtionnal_2_entity_container_year = self.entities[3] self.list_repartition_volume_entities = [ self.requirement_entity_container_year, self.additionnal_1_entity_container_year, self.addtionnal_2_entity_container_year ] self.learning_container_year = LearningContainerYearFactory( learning_container=learning_container, academic_year=self.academic_year, container_type=learning_container_year_types.COURSE, acronym="LDROI1200", common_title="Droit international", common_title_english="Droit international english", requirement_entity=self.requirement_entity_container_year, allocation_entity=self.allocation_entity_container_year, additional_entity_1=self.additionnal_1_entity_container_year, additional_entity_2=self.addtionnal_2_entity_container_year, ) self.learning_container = self.learning_container_year.learning_container
def test_with_post_and_webservice_is_available(self, mock_fetch): today = datetime.datetime.today() an_academic_year = AcademicYearFactory( year=today.year, start_date=today - datetime.timedelta(days=5), end_date=today + datetime.timedelta(days=5)) a_learning_container_year = LearningContainerYearFactory( academic_year=an_academic_year) a_learning_unit_year = LearningUnitYearFactory( academic_year=an_academic_year, learning_container_year=a_learning_container_year) AttributionFactory(learning_unit_year=a_learning_unit_year, tutor=self.tutor) key = '{}{}'.format(LEARNING_UNIT_ACRONYM_ID, a_learning_unit_year.acronym) response = self.client.post(self.url, data={key: ""}) filename = "Liste_Insc_Exam.xls" self.assertEqual(response.status_code, OK) self.assertTrue(mock_fetch.called) self.assertEqual( response['Content-Type'], 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ) self.assertEqual(response['Content-Disposition'], 'attachment; filename="{}"'.format(filename)) self.assertEqual(response.content.decode(), str(return_sample_xls()))
def setUp(self): today = date.today() self.academic_year = AcademicYearFactory(year=today.year, start_date=today) # Creation Container / UE and components related self.l_container = LearningContainerYearFactory(academic_year=self.academic_year, acronym="LBIR1210", in_charge=True) _create_learning_unit_year_with_components(academic_year=self.academic_year, l_container=self.l_container, acronym="LBIR1210",subtype=learning_unit_year_subtypes.FULL) _create_learning_unit_year_with_components(academic_year=self.academic_year, l_container=self.l_container, acronym="LBIR1210A", subtype=learning_unit_year_subtypes.PARTIM) _create_learning_unit_year_with_components(academic_year=self.academic_year, l_container=self.l_container, acronym="LBIR1210B", subtype=learning_unit_year_subtypes.PARTIM) # Creation Tutors self.tutor_1 = TutorFactory(person=PersonFactory(first_name="Tom", last_name="Dupont", global_id='00012345')) self.tutor_2 = TutorFactory(person=PersonFactory(first_name="Paul", last_name="Durant", global_id='08923545')) # Creation Attribution and Attributions Charges - Tutor 1 - Holder attribution_tutor_1 = AttributionNewFactory(learning_container_year=self.l_container, tutor=self.tutor_1, function=function.HOLDER) _create_attribution_charge(self.academic_year, attribution_tutor_1, "LBIR1210", Decimal(15.5), Decimal(10)) _create_attribution_charge(self.academic_year, attribution_tutor_1, "LBIR1210A", None, Decimal(5)) # Creation Attribution and Attributions Charges - Tutor 2 - Co-holder attribution_tutor_2 = AttributionNewFactory(learning_container_year=self.l_container, tutor=self.tutor_2, function=function.CO_HOLDER) _create_attribution_charge(self.academic_year, attribution_tutor_2, "LBIR1210B", Decimal(7.5))