コード例 #1
0
    def test_save_update(self):
        formset = SimplifiedVolumeManagementForm(
            self.data,
            queryset=LearningComponentYear.objects.filter(
                learningunitcomponent__learning_unit_year=self.
                learning_unit_year))

        self.assertEqual(len(formset.forms), 2)
        self.assertTrue(formset.is_valid())

        learning_component_years = formset.save_all_forms(
            self.learning_unit_year, self.entity_container_years)

        cm_component = learning_component_years[0]
        tp_component = learning_component_years[1]

        self.assertEqual(
            cm_component.learningunitcomponent_set.get().learning_unit_year,
            self.learning_unit_year)
        self.assertEqual(
            tp_component.learningunitcomponent_set.get().learning_unit_year,
            self.learning_unit_year)

        self.assertEqual(cm_component.type, LECTURING)
        self.assertEqual(tp_component.type, PRACTICAL_EXERCISES)

        self.assertEqual(cm_component.entitycomponentyear_set.count(), 3)
        self.assertEqual(tp_component.entitycomponentyear_set.count(), 3)
コード例 #2
0
    def test_save_correct_planned_classes(self):
        strange_data = {
            'component-TOTAL_FORMS': '2',
            'component-INITIAL_FORMS': '0',
            'component-MAX_NUM_FORMS': '2',
            'component-0-hourly_volume_total_annual': 0,
            'component-0-hourly_volume_partial_q1': 0,
            'component-0-hourly_volume_partial_q2': 0,
            'component-1-hourly_volume_total_annual': 20,
            'component-1-hourly_volume_partial_q1': 10,
            'component-1-hourly_volume_partial_q2': 10,
        }

        formset = SimplifiedVolumeManagementForm(
            strange_data,
            self.person,
            queryset=LearningComponentYear.objects.none())
        self.assertEqual(len(formset.forms), 2)
        self.assertTrue(formset.is_valid())

        learning_component_years = formset.save_all_forms(
            self.learning_unit_year, self.entity_container_years)

        component_with_volume_nul = learning_component_years[0]
        component_with_volume_not_null = learning_component_years[1]

        self.assertEqual(component_with_volume_nul.planned_classes, 0)
        self.assertEqual(component_with_volume_not_null.planned_classes, 1)
コード例 #3
0
    def test_save_with_master_thesis_container_type(self):
        formset = SimplifiedVolumeManagementForm(self.data, self.person, queryset=LearningComponentYear.objects.none())
        self.assertEqual(len(formset.forms), 2)
        self.assertTrue(formset.is_valid())

        learning_component_years = formset.save_all_forms(self.learning_unit_year, self.entity_container_years)

        cm_component = learning_component_years[0]
        tp_component = learning_component_years[1]

        self.assertEqual(cm_component.learning_unit_year, self.learning_unit_year)
        self.assertEqual(tp_component.learning_unit_year, self.learning_unit_year)

        self.assertEqual(cm_component.type, LECTURING)
        self.assertEqual(tp_component.type, PRACTICAL_EXERCISES)