Ejemplo n.º 1
0
 def test_should_change_school_and_location_when_reporters_school_and_location_dont_match(self):
     data = {'reporting_location':self.kampala_district.id,'schools':self.school1.id}
     self.emis_reporter.schools.add(self.school2)
     self.emis_reporter.reporting_location = self.masaka_district
     self.emis_reporter.save()
     edit_emis_reporter_form = EditReporterForm(instance = self.emis_reporter, data = data)
     self.assertTrue(edit_emis_reporter_form.is_valid())
Ejemplo n.º 2
0
 def test_should_save_successfully_given_correct_data(self):
     self.emis_reporter.schools.add(self.school1)
     self.emis_reporter.save()
     data={'name': 'Foo Bar', 'reporting_location':self.kampala_district.id}
     edit_emis_reporter_form = EditReporterForm(instance=self.emis_reporter, data=data)
     edit_emis_reporter_form.save()
     self.assertTrue('Foo Bar' in EmisReporter.objects.all().values_list('name', flat=True))
Ejemplo n.º 3
0
 def test_should_not_save_when_school_is_in_wrong_location(self):
     self.emis_reporter.reporting_location = self.kampala_district
     self.emis_reporter.schools.add(self.school3)
     self.emis_reporter.save()
     edit_emis_reporter_form = EditReporterForm(
         instance=self.emis_reporter, data={'reporting_location':self.kampala_district.id,'schools':self.school3.id})
     self.assertFalse(edit_emis_reporter_form.is_valid())
Ejemplo n.º 4
0
 def test_adding_school_from_different_location_should_create_form_error_schools(self):
     self.emis_reporter.reporting_location = self.kampala_district
     self.emis_reporter.schools.add(self.school3)
     self.emis_reporter.save()
     edit_emis_reporter_form = EditReporterForm(
         instance=self.emis_reporter, data={'reporting_location':self.kampala_district.id,'schools':self.school3.id})
     edit_emis_reporter_form.is_valid()
     self.assertTrue("schools" in edit_emis_reporter_form._errors.keys())
Ejemplo n.º 5
0
 def test_should_be_able_to_edit_when_reporter_has_school_but_no_location(self):
     self.emis_reporter.schools.add(self.school1)
     self.emis_reporter.save()
     data={'reporting_location':self.kampala_district.id, 'schools':self.school2.id}
     edit_emis_reporter_form = EditReporterForm(instance = self.emis_reporter, data=data)
     self.assertTrue(edit_emis_reporter_form.is_valid())