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): 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_entity_component_year(luy, component_type, entity_container_year, repartition_volume): a_learning_unit_component = LearningUnitComponent.objects.get( learning_unit_year=luy, learning_component_year__type=component_type) EntityComponentYearFactory( entity_container_year=entity_container_year, learning_component_year=a_learning_unit_component. learning_component_year, repartition_volume=repartition_volume)
def _assign_volume(container_year, component_year, map_entity_type_and_volume): for entity_type, volume in map_entity_type_and_volume.items(): entity_cont = EntityContainerYearFactory( type=entity_type, learning_container_year=container_year) EntityComponentYearFactory( entity_container_year=entity_cont, learning_component_year=component_year, hourly_volume_total=volume.get('vol_tot'), hourly_volume_partial=volume.get('vol_partial'))
def _setup_entity_component_year(learning_component_year, entity_container_year): return EntityComponentYearFactory(learning_component_year=learning_component_year, entity_container_year=entity_container_year, repartition_volume=0)