コード例 #1
0
    def setUp(self):
        self.test_form = LocationForm()
        self.test_form.data = {
            'q_stmt': u'',
            'ages': u'',
            'e_info': u'',
            'site_affil': u'',
            'is_age_lt_3': None,
            'prg_dur': u'',
            'exec_director': u'',
            'city': u'Chicago',
            'lat_and_long': False,
            'ctr_director': u'',
            'zip': u'60611',
            'is_tuition_based': None,
            'state': u'IL',
            'geom': u'',
            'is_age_gt_3': None,
            'prg_sched': u'',
            'email': u'',
            'accred': u'',
            'is_child_care': None,
            'is_hs': None,
            'fax': u'',
            'as_proc': u'',
            'is_montessori': None,
            'waitlist': u'',
            'phone2': u'',
            'phone3': u'',
            'phone1': u'555 555 5555',
            'is_pre4all': None,
            'address': u'301 E North Water St',
            'is_ehs': None,
            'is_special_ed': None,
            'url': u'',
            'is_child_parent_center': None,
        }

        self.test_form.cleaned_data = self.test_form.data
コード例 #2
0
 def setUp(self):
     self.test_form = LocationForm()
     self.test_form.data = {'q_stmt': u'', 'ages': u'',
                            'e_info': u'', 'site_affil': u'', 'is_age_lt_3': None, 'prg_dur': u'',
                            'exec_director': u'', 'city': u'Chicago', 'lat_and_long': False,
                            'ctr_director': u'', 'zip': u'60611', 'is_tuition_based': None,
                            'state': u'IL', 'geom': u'',
                            'is_age_gt_3': None, 'prg_sched': u'', 'email': u'', 'accred': u'',
                            'is_child_care': None, 'is_hs': None, 'fax': u'', 'as_proc': u'',
                            'is_montessori': None, 'waitlist': u'', 'phone2': u'', 'phone3': u'',
                            'phone1': u'555 555 5555', 'is_pre4all': None,
                            'address': u'301 E North Water St', 'is_ehs': None,
                            'is_special_ed': None, 'url': u'', 'is_child_parent_center': None}
     self.test_form.cleaned_data = self.test_form.data
コード例 #3
0
class CustomAdminForm(TestCase):
    """
    Unit tests for admin.LocationForm to make sure form validation
    still works after subclassing
    """

    def setUp(self):
        self.test_form = LocationForm()
        self.test_form.data = {
            'q_stmt': u'', 'ages': u'',
            'e_info': u'', 'site_affil': u'', 'is_age_lt_3': None, 'prg_dur': u'',
            'exec_director': u'', 'city': u'Chicago', 'lat_and_long': False,
            'ctr_director': u'', 'zip': u'60611', 'is_tuition_based': None,
            'state': u'IL', 'geom': u'',
            'is_age_gt_3': None, 'prg_sched': u'', 'email': u'', 'accred': u'',
            'is_child_care': None, 'is_hs': None, 'fax': u'', 'as_proc': u'',
            'is_montessori': None, 'waitlist': u'', 'phone2': u'', 'phone3': u'',
            'phone1': u'555 555 5555', 'is_pre4all': None,
            'address': u'301 E North Water St', 'is_ehs': None,
            'is_special_ed': None, 'url': u'', 'is_child_parent_center': None,
        }

        self.test_form.cleaned_data = self.test_form.data

    def test_saving_empy_point(self):
        """Test that clean method correctly throws a validation error if no point in form"""
        self.test_form.clean()
        self.assertFalse(self.test_form.is_valid())

    def test_saving_invalid_point(self):
        """Test that clean method correctly throws a validation error if point is gibberish"""
        self.test_form.cleaned_data['geom'] = 'gibberish'
        self.test_form.clean()
        self.assertFalse(self.test_form.is_valid())

    def test_saving_valid_point(self):
        """Test that clean method correctly handles a well-formatted Point"""
        self.test_form.cleaned_data['geom'] = 'POINT (-12.213123213 100.112343674)'
        try:
            self.test_form.clean()
        except forms.ValidationError:
            self.assertFail('Should be able to save a valid point from the LocationForm')
コード例 #4
0
class CustomAdminForm(TestCase):
    """
    Unit tests for admin.LocationForm to make sure form validation
    still works after subclassing
    """
    def setUp(self):
        self.test_form = LocationForm()
        self.test_form.data = {
            'q_stmt': u'',
            'ages': u'',
            'e_info': u'',
            'site_affil': u'',
            'is_age_lt_3': None,
            'prg_dur': u'',
            'exec_director': u'',
            'city': u'Chicago',
            'lat_and_long': False,
            'ctr_director': u'',
            'zip': u'60611',
            'is_tuition_based': None,
            'state': u'IL',
            'geom': u'',
            'is_age_gt_3': None,
            'prg_sched': u'',
            'email': u'',
            'accred': u'',
            'is_child_care': None,
            'is_hs': None,
            'fax': u'',
            'as_proc': u'',
            'is_montessori': None,
            'waitlist': u'',
            'phone2': u'',
            'phone3': u'',
            'phone1': u'555 555 5555',
            'is_pre4all': None,
            'address': u'301 E North Water St',
            'is_ehs': None,
            'is_special_ed': None,
            'url': u'',
            'is_child_parent_center': None
        }
        self.test_form.cleaned_data = self.test_form.data

    def test_saving_empy_point(self):
        """Test that clean method correctly throws a validation error if no point in form"""
        try:
            self.test_form.clean()
            self.assertFail('Should be able to save a point from a string')
        except forms.ValidationError:
            pass

    def test_saving_invalid_point(self):
        """Test that clean method correctly throws a validation error if point is gibberish"""
        self.test_form.cleaned_data['geom'] = 'gibberish'
        try:
            self.test_form.clean()
            self.assertFail('Should not be able to save a point of gibberish')
        except forms.ValidationError:
            pass

    def test_saving_valid_point(self):
        """Test that clean method correctly handles a well-formatted Point"""
        self.test_form.cleaned_data[
            'geom'] = 'POINT (-12.213123213 100.112343674)'
        try:
            self.test_form.clean()
        except forms.ValidationError:
            self.assertFail(
                'Should be able to save a valid point from the LocationForm')