Пример #1
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
Пример #2
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())
Пример #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())
Пример #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'))
Пример #5
0
 def test_get_entity_fields(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)
         actual_entity_fields = form.get_entity_fields()
         self.assertEqual(len(actual_entity_fields), 3)
Пример #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
Пример #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)
Пример #8
0
    def test_get_volume_form(self):
        for component, component_values in self.learning_unit_with_context.components.items():
            component_values = VolumeEditionBaseFormset._clean_component_keys(component_values)
            form = VolumeEditionForm(learning_unit_year=self.learning_unit_with_context,
                                     initial=component_values,
                                     component=component,
                                     entities=self.learning_unit_with_context.entities)

            self.assertEqual(form.initial, component_values)
Пример #9
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.'))
Пример #10
0
 def test_compare(self):
     self.assertFalse(VolumeEditionForm._compare(0, 0, False))
     self.assertTrue(VolumeEditionForm._compare(12, 14, False))
     self.assertTrue(VolumeEditionForm._compare(12, 12, True))
     self.assertFalse(VolumeEditionForm._compare(12, 12, False))