Add more test cases for validators

This commit is contained in:
Stefan Haun 2020-11-07 13:19:55 +01:00 committed by David Kilias
parent 56b8d9def0
commit a41573bffb

View file

@ -6,9 +6,11 @@ def test_mandatory():
assert mandatory("Foo Bar") == True assert mandatory("Foo Bar") == True
assert mandatory("1970-01-01") == True assert mandatory("1970-01-01") == True
assert mandatory("") == False assert mandatory("") == False
assert mandatory(None) == False
def test_empty(): def test_empty():
assert empty(None) == True
assert empty("") == True assert empty("") == True
assert empty(" ") == False assert empty(" ") == False
assert empty("Foo") == False assert empty("Foo") == False
@ -22,12 +24,18 @@ def test_iso_date():
assert iso_date("1970/01/01") == False assert iso_date("1970/01/01") == False
assert iso_date("1.1.1970") == False assert iso_date("1.1.1970") == False
assert iso_date("01.01.1970") == False assert iso_date("01.01.1970") == False
assert iso_date("") == False
assert iso_date(None) == False
def test_valid_iban(): def test_valid_iban():
assert valid_iban("DE89 3704 0044 0532 0130 00") == True assert valid_iban("DE89 3704 0044 0532 0130 00") == True
assert valid_iban("DE89370400440532013000") == True
assert valid_iban("DX89 3704 0044 0532 0130 00") == False assert valid_iban("DX89 3704 0044 0532 0130 00") == False
assert valid_iban("DE99 3704 0044 0532 0130 00") == False assert valid_iban("DE99 3704 0044 0532 0130 00") == False
assert valid_iban("") == False
assert valid_iban(None) == False
assert valid_iban("DE89 3704 0044 0532 0130 00".split()) == False
def test_valid_bic(): def test_valid_bic():
@ -35,3 +43,8 @@ def test_valid_bic():
assert valid_bic("PBNKDXFFXXX") == False assert valid_bic("PBNKDXFFXXX") == False
assert valid_bic("PBNKDXFFXXXX") == False assert valid_bic("PBNKDXFFXXXX") == False
assert valid_bic("PBN1DXFFXXX") == False assert valid_bic("PBN1DXFFXXX") == False
assert valid_bic("") == False
assert valid_bic(None) == False
assert valid_bic("PBNKDEFFXXX".split()) == False