Example #1
0
 def test_save_hopsform_without_ares_data(self):
     form_education_group_year = HopsEducationGroupYearModelForm(
         data={}, instance=self.hops)
     self.assertTrue(form_education_group_year.is_valid())
     hops_updated = form_education_group_year.save(
         education_group_year=self.parent_education_group_year)
     self.assertIsNone(hops_updated)
Example #2
0
 def test_not_valid_hopsform(self):
     form_education_group_year = HopsEducationGroupYearModelForm(
         data={
             'ares_study': 1,
         },
         instance=self.hops)
     self.assertFalse(form_education_group_year.is_valid())
     self.assertEqual(list(form_education_group_year.errors['ares_study'])[0],
                      _('The fields concerning ARES have to be ALL filled-in or none of them'))
Example #3
0
 def test_save_hopsform(self):
     form_education_group_year = HopsEducationGroupYearModelForm(
         data={
             'ares_study': 10,
             'ares_graca': 20,
             'ares_ability': 30,
         },
         instance=self.hops)
     if form_education_group_year.is_valid():
         hops_updated = form_education_group_year.save(
             education_group_year=self.parent_education_group_year)
         self.assertEqual(hops_updated.ares_study, 10)
         self.assertEqual(hops_updated.ares_graca, 20)
         self.assertEqual(hops_updated.ares_ability, 30)
         self.assertEqual(hops_updated.id, self.hops.id)
Example #4
0
 def test_valid_hopsform(self):
     form_education_group_year = HopsEducationGroupYearModelForm(
         data={
             'ares_study': 1,
             'ares_graca': 2,
             'ares_ability': 3,
         },
         instance=self.hops
     )
     self.assertFalse(form_education_group_year.fields["ares_study"].required)
     self.assertFalse(form_education_group_year.fields["ares_graca"].required)
     self.assertFalse(form_education_group_year.fields["ares_ability"].required)