def test_invalid_form_should_not_save_successfully(self):
     data = {
         "name" : 1,
         "location" : self.kampala_district
     }
     school = SchoolForm(data)
     self.assertRaises(TypeError, lambda : school.save())
 def test_valid_form_should_save_successfully(self):
     data = {
         "name": "St.Mary's Fairway Primary school",
         "location" : self.kampala_district.id
     }
     school = SchoolForm(data)
     school.save()
     self.assertTrue("St.Mary's Fairway Primary school" in School.objects.all().values_list('name', flat=True))
Example #3
0
 def test_valid_form_should_save_successfully(self):
     data = {
         "name": "St.Mary's Fairway Primary school",
         "location": self.kampala_district.id
     }
     school = SchoolForm(data)
     school.save()
     self.assertTrue("St.Mary's Fairway Primary school" in
                     School.objects.all().values_list('name', flat=True))
Example #4
0
 def test_form_should_have_all_districts(self):
     school_form = SchoolForm()
     School.objects.create(name="St.Mary's Fairway",
                           location=self.kampala_district)
     districts = Location.objects.filter(type='district')
     self.assertEquals(
         districts.count(),
         school_form.fields['location'].queryset.all().count())
 def test_empty_should_not_be_valid(self):
     school_form = SchoolForm()
     self.assertFalse(school_form.is_valid())
Example #6
0
 def test_invalid_form_should_not_save_successfully(self):
     data = {"name": 1, "location": self.kampala_district}
     school = SchoolForm(data)
     self.assertRaises(TypeError, lambda: school.save())
Example #7
0
 def test_empty_should_not_be_valid(self):
     school_form = SchoolForm()
     self.assertFalse(school_form.is_valid())
Example #8
0
 def test_empty_form_should_not_be_bound(self):
     school_form = SchoolForm()
     self.assertFalse(school_form.is_bound)