Esempio n. 1
0
 def test_post_volume_form_empty_field(self):
     for component, component_values in self.learning_unit_with_context.components.items():
         component_values = VolumeEditionBaseFormset._clean_component_keys(component_values)
         form = VolumeEditionForm(
             data=_get_wrong_data_empty_field(),
             learning_unit_year=self.learning_unit_with_context,
             initial=component_values,
             component=component,
             entities=self.learning_unit_with_context.entities)
         self.assertFalse(form.is_valid())
Esempio n. 2
0
 def test_post_volume_form_wrong_volume_tot_requirement(self):
     for component, component_values in self.learning_unit_with_context.components.items():
         component_values = VolumeEditionBaseFormset._clean_component_keys(component_values)
         form = VolumeEditionForm(
             data=_get_wrong_data_volume_tot(),
             learning_unit_year=self.learning_unit_with_context,
             initial=component_values,
             component=component,
             entities=self.learning_unit_with_context.entities)
         self.assertTrue(form.is_valid()) # Accept that vol_tot * cp is not equal to vol_global
Esempio n. 3
0
 def test_post_volume_form_partim_q1(self):
     for component, component_values in self.learning_unit_with_context.components.items():
         component_values = VolumeEditionBaseFormset._clean_component_keys(component_values)
         form = VolumeEditionForm(
             data=_get_valid_partim_data_alter(),
             learning_unit_year=self.learning_unit_with_context,
             initial=component_values,
             component=component,
             entities=self.learning_unit_with_context.entities)
         self.assertTrue(form.is_valid())
Esempio n. 4
0
 def test_post_volume_form_wrong_volume_total(self):
     for component, component_values in self.learning_unit_with_context.components.items():
         component_values = VolumeEditionBaseFormset._clean_component_keys(component_values)
         form = VolumeEditionForm(
             data=_get_wrong_data_volume_tot(),
             learning_unit_year=self.learning_unit_with_context,
             initial=component_values,
             component=component,
             entities=self.learning_unit_with_context.entities)
         self.assertFalse(form.is_valid())
         self.assertEqual(form.errors['volume_total'][0], _('vol_tot_not_equal_to_q1_q2'))
Esempio n. 5
0
    def test_volume_edition_as_faculty_manager(self):
        component = LearningComponentYearFactory()
        form = VolumeEditionForm(
            data={
                'volume_q1': 12,
                'volume_q2': 12,
                'volume_total': 24
            },
            component=component,
            learning_unit_year=self.learning_unit_year_full,
            is_faculty_manager=True,
            initial={
                'volume_q1': 0,
                'volume_q2': 12
            })

        form.is_valid()
        self.assertEqual(
            form.errors['volume_q2'][1],
            gettext('One of the partial volumes must have a value to 0.'))
        self.assertEqual(
            form.errors['volume_q1'][1],
            gettext('One of the partial volumes must have a value to 0.'))

        form = VolumeEditionForm(
            data={
                'volume_q1': 0,
                'volume_q2': 12,
                'volume_total': 24
            },
            component=component,
            learning_unit_year=self.learning_unit_year_full,
            is_faculty_manager=True,
            initial={
                'volume_q1': 12,
                'volume_q2': 12
            })

        form.is_valid()
        self.assertEqual(form.errors['volume_q1'][1],
                         gettext('The volume can not be set to 0.'))

        form = VolumeEditionForm(
            data={
                'volume_q1': 12,
                'volume_q2': 0,
                'volume_total': 24
            },
            component=component,
            learning_unit_year=self.learning_unit_year_full,
            is_faculty_manager=True,
            initial={
                'volume_q1': 12,
                'volume_q2': 12
            })

        form.is_valid()
        self.assertEqual(form.errors['volume_q2'][1],
                         gettext('The volume can not be set to 0.'))
Esempio n. 6
0
 def test_post_volume_form_wrong_vol_req_entity(self):
     for component, component_values in self.learning_unit_with_context.components.items(
     ):
         component_values = VolumeEditionBaseFormset._clean_component_keys(
             component_values)
         form = VolumeEditionForm(
             data=_get_wrong_data_vol_req_entity(),
             learning_unit_year=self.learning_unit_with_context,
             initial=component_values,
             component=component,
             entities=self.learning_unit_with_context.entities)
         self.assertFalse(
             form.is_valid()
         )  # Don't accept that vol_global is not equal to sum of volumes of entities
Esempio n. 7
0
    def test_post_volume_form_wrong_vol_req_entity(self):
        for component, component_values in self.learning_unit_with_context.components.items():
            component_values = VolumeEditionBaseFormset._clean_component_keys(component_values)
            form = VolumeEditionForm(
                data=_get_wrong_data_vol_req_entity(),
                learning_unit_year=self.learning_unit_with_context,
                initial=component_values,
                component=component,
                entities=self.learning_unit_with_context.entities)
            self.assertFalse(form.is_valid())

            error_msg = ' + '.join([self.learning_unit_with_context.entities.get(t).acronym for t in ENTITY_TYPES_VOLUME
                                    if self.learning_unit_with_context.entities.get(t)])
            error_msg += ' = {}'.format(_('vol_charge'))
            self.assertEqual(form.errors['volume_total_requirement_entities'][0], error_msg)