dav_base: Improved DAVNumberValidator (and tests for that)
Run tests / Execute tox to run the test suite (push) Successful in 3m24s
Run tests / Execute tox to run the test suite (push) Successful in 3m24s
This commit is contained in:
@@ -10,28 +10,49 @@ class DAVNumberValidatorTestCase(ValidatorTestMixin, SimpleTestCase):
|
|||||||
|
|
||||||
def test_valid_data(self):
|
def test_valid_data(self):
|
||||||
data = (
|
data = (
|
||||||
|
'001/00/1*0001*1869*1869*01011800',
|
||||||
|
'999/99/999999*9999*2025*2026',
|
||||||
|
'131/00/654321*1000*1999',
|
||||||
|
'131/00/54321*1000',
|
||||||
'131/00/1',
|
'131/00/1',
|
||||||
|
'076/22/012345',
|
||||||
'1',
|
'1',
|
||||||
'22',
|
'23',
|
||||||
'333',
|
'4567',
|
||||||
'1/22/22',
|
'678912',
|
||||||
'54321/54321/54321*54321',
|
'999999*9999',
|
||||||
'54321/54321/54321*54321*4321*4321',
|
'54321x0001x2004',
|
||||||
'54321/54321/54321*54321*4321*4321*87654321',
|
'54321 0001 2004 2014',
|
||||||
'54321*54321',
|
'4321*0202x1999 2022*30121999',
|
||||||
'54321*54321*4321*4321',
|
|
||||||
'54321*54321*4321*4321*87654321',
|
|
||||||
)
|
)
|
||||||
self.assertValid(self.validator, data)
|
self.assertValid(self.validator, data)
|
||||||
|
|
||||||
def test_invalid_data(self):
|
def test_invalid_data(self):
|
||||||
data = (
|
data = (
|
||||||
'131/00/',
|
'1/00/1', # Sektionsnummer nicht dreistellig
|
||||||
'1/1/1',
|
'21/00/1', # Sektionsnummer nicht dreistellig
|
||||||
'1/1',
|
'4321/00/1', # Sektionsnummer nicht dreistellig
|
||||||
'abc',
|
'131/1/1', # Ortsgruppennummer nicht zweistellig
|
||||||
'131/00/abc',
|
'131/321/1', # Ortsgruppennummer nicht zweistellig
|
||||||
'abc/00/131',
|
'131/00/', # Fehlende Mitgliedsnummer
|
||||||
'131/ab/131',
|
'131/00', # Fehlende Mitgliedsnummer
|
||||||
|
'7654321' # Mitgliedsnummer mehr als sechs Stellen
|
||||||
|
'999999*321' # Kategorienummer nicht vierstellig
|
||||||
|
'999999*54321' # Kategorienummer nicht vierstellig
|
||||||
|
'999999*9999*321' # DAV-Eintrittsjahr nicht vierstellig
|
||||||
|
'999999*9999*54321' # DAV-Eintrittsjahr nicht vierstellig
|
||||||
|
'999999*9999*9999*321' # Sektions-Eintrittsjahr nicht vierstellig
|
||||||
|
'999999*9999*9999*54321' # Sektions-Eintrittsjahr nicht vierstellig
|
||||||
|
'999999*9999*9999*9999*7654321' # Geburtsdatum nicht achtstellig
|
||||||
|
'999999*9999*9999*9999*987654321' # Geburtsdatum nicht achtstellig
|
||||||
|
'' # Leerstring
|
||||||
|
' 1' # Leerzeichen am Anfang
|
||||||
|
'54321 0001 2004 2014 ' # Leerzeichen am Ende
|
||||||
|
'abc', # Nicht numerisch
|
||||||
|
'131/00/abc', # Nicht numerisch
|
||||||
|
'abc/00/131', # Nicht numerisch
|
||||||
|
'131/ab/131', # Nicht numerisch
|
||||||
|
'131-00-131', # - statt /
|
||||||
|
'131/00/131-0001', # - statt * oder x oder Leerzeichen
|
||||||
)
|
)
|
||||||
self.assertInvalid(self.validator, data)
|
self.assertInvalid(self.validator, data)
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
|
|
||||||
|
|
||||||
DAVNumberValidator = RegexValidator(r'^'
|
DAVNumberValidator = RegexValidator(r'^'
|
||||||
r'([0-9]{1,10}/[0-9]{2,10}/)?'
|
r'([0-9]{3}/[0-9]{2}/)?'
|
||||||
r'[0-9]{1,10}'
|
r'[0-9]{1,6}'
|
||||||
r'(\*[0-9]{1,10})?'
|
r'([*x ][0-9]{1,4})?'
|
||||||
r'(\*[0-9]{4}\*[0-9]{4})?'
|
r'([*x ][0-9]{4}[*x ][0-9]{4})?'
|
||||||
r'([* ][0-9]{8})?'
|
r'([*x ][0-9]{8})?'
|
||||||
r'$',
|
r'$',
|
||||||
_('Ungültiges Format.'))
|
_('Ungültiges Format.'))
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ class EmailsTestCase(EmailTestMixin, EventMixin, RegistrationMixin, TestCase):
|
|||||||
'year_of_birth': 1976,
|
'year_of_birth': 1976,
|
||||||
'apply_reduced_fee': True,
|
'apply_reduced_fee': True,
|
||||||
'dav_member': False,
|
'dav_member': False,
|
||||||
'dav_number': '131/00/007*12345',
|
'dav_number': '131/00/007*1234',
|
||||||
'emergency_contact': 'Call 911!',
|
'emergency_contact': 'Call 911!',
|
||||||
'experience': 'Yes, we can!',
|
'experience': 'Yes, we can!',
|
||||||
'note': 'Automatischer Software Test\nGruß\n heinzel =u}',
|
'note': 'Automatischer Software Test\nGruß\n heinzel =u}',
|
||||||
@@ -277,7 +277,7 @@ class EmailsTestCase(EmailTestMixin, EventMixin, RegistrationMixin, TestCase):
|
|||||||
'year_of_birth': THIS_YEAR,
|
'year_of_birth': THIS_YEAR,
|
||||||
'apply_reduced_fee': True,
|
'apply_reduced_fee': True,
|
||||||
'dav_member': False,
|
'dav_member': False,
|
||||||
'dav_number': '131/00/007*12345',
|
'dav_number': '131/00/007*1234',
|
||||||
'emergency_contact': 'Call 911!',
|
'emergency_contact': 'Call 911!',
|
||||||
'experience': 'Yes, we can!',
|
'experience': 'Yes, we can!',
|
||||||
'note': 'Automatischer Software Test\nGruß\n heinzel =u}',
|
'note': 'Automatischer Software Test\nGruß\n heinzel =u}',
|
||||||
|
|||||||
Reference in New Issue
Block a user