示例#1
0
文件: tests.py 项目: Giftovus/django
    def test_umcn_invalid(self):
        """
        Test that UMCNFields throw appropriate errors for invalid UMCNs.
        """
        form = MKPersonForm({
            'first_name':'Someone',
            'last_name':'Something',
            'umcn': '2402983450007',
            'municipality':'OD',
            'municipality_req':'VE',
            'id_number':'A1234567',
        })
        self.assertFalse(form.is_valid())
        self.assertEqual(form.errors['umcn'], [u'The UMCN is not valid.'])

        form = MKPersonForm({
            'first_name':'Someone',
            'last_name':'Something',
            'umcn': '3002983450007',
            'municipality':'OD',
            'municipality_req':'VE',
            'id_number':'A1234567',
        })
        self.assertEqual(form.errors['umcn'],
                [u'The first 7 digits of the UMCN must represent a valid past date.'])
示例#2
0
    def test_umcn_invalid(self):
        """
        Test that UMCNFields throw appropriate errors for invalid UMCNs.
        """
        form = MKPersonForm({
            'first_name': 'Someone',
            'last_name': 'Something',
            'umcn': '2402983450007',
            'municipality': 'OD',
            'municipality_req': 'VE',
            'id_number': 'A1234567',
        })
        self.assertFalse(form.is_valid())
        self.assertEqual(form.errors['umcn'], [u'The UMCN is not valid.'])

        form = MKPersonForm({
            'first_name': 'Someone',
            'last_name': 'Something',
            'umcn': '3002983450007',
            'municipality': 'OD',
            'municipality_req': 'VE',
            'id_number': 'A1234567',
        })
        self.assertEqual(form.errors['umcn'], [
            u'The first 7 digits of the UMCN must represent a valid past date.'
        ])
示例#3
0
    def test_municipality_required(self):
        """Test that required MKMunicipalityFields throw appropriate errors."""

        form = MKPersonForm({'first_name':'Someone',
                             'last_name':'Something',
                             'umcn': '2402983450006',
                             'municipality':'OD',
                             'id_number':'A1234567'})
        
        self.assertFalse(form.is_valid())
        self.assertEqual(form.errors['municipality_req'], [u'This field is required.'])
示例#4
0
    def test_idnumber_invalid(self):
        """Test that MKIdentityCardNumberFields throw appropriate errors for invalid values"""

        form = MKPersonForm({'first_name':'Someone',
                             'last_name':'Something',
                             'umcn': '2402983450007',
                             'municipality':'OD',
                             'municipality_req':'VE',
                             'id_number':'A123456a'})
        
        self.assertFalse(form.is_valid())
        self.assertEqual(form.errors['id_number'],\
                         [u'Identity card numbers must contain'\
                              ' either 4 to 7 digits or an uppercase letter and 7 digits.'])
示例#5
0
    def test_municipality_required(self):
        """Test that required MKMunicipalityFields throw appropriate errors."""

        form = MKPersonForm({
            'first_name': 'Someone',
            'last_name': 'Something',
            'umcn': '2402983450006',
            'municipality': 'OD',
            'id_number': 'A1234567'
        })

        self.assertFalse(form.is_valid())
        self.assertEqual(form.errors['municipality_req'],
                         [u'This field is required.'])
示例#6
0
    def test_idnumber_invalid(self):
        """Test that MKIdentityCardNumberFields throw appropriate errors for invalid values"""

        form = MKPersonForm({
            'first_name': 'Someone',
            'last_name': 'Something',
            'umcn': '2402983450007',
            'municipality': 'OD',
            'municipality_req': 'VE',
            'id_number': 'A123456a'
        })

        self.assertFalse(form.is_valid())
        self.assertEqual(form.errors['id_number'],\
                         [u'Identity card numbers must contain'\
                              ' either 4 to 7 digits or an uppercase letter and 7 digits.'])