@@ -34,6 +34,40 @@ def test_parse_3_words():
3434 assert document .issuing_authority is None
3535
3636
37+ def test_parse_redacted_aadhaar ():
38+ DATA = "AADHAAR IND ****1234"
39+
40+ document = DocumentDetails (DATA )
41+
42+ assert document .document_type == "AADHAAR"
43+ assert document .issuing_country == "IND"
44+ assert document .document_number == "****1234"
45+ assert document .expiration_date is None
46+ assert document .issuing_authority is None
47+
48+
49+ @pytest .mark .parametrize (
50+ "details, expected_number" ,
51+ [
52+ ("type country **** - authority" , "****" ),
53+ (
54+ "type country ~!@#$%^&*()-_=+[]{}|;':,./<>? - authority" ,
55+ "~!@#$%^&*()-_=+[]{}|;':,./<>?" ,
56+ ),
57+ ('type country "" - authority' , '""' ),
58+ ("type country \\ - authority" , "\\ " ),
59+ ('type country " - authority' , '"' ),
60+ ("type country '' - authority" , "''" ),
61+ ("type country ' - authority" , "'" ),
62+ ],
63+ )
64+ def test_parse_special_characters (details , expected_number ):
65+ document = DocumentDetails (details )
66+
67+ assert document .document_type == "type"
68+ assert document .document_number == expected_number
69+
70+
3771def test_parse_4_words ():
3872 DATA = "DRIVING_LICENCE GBR 1234abc 2016-05-01"
3973
@@ -88,3 +122,11 @@ def test_invalid_date():
88122 with pytest .raises (ValueError ) as exc :
89123 DocumentDetails (DATA )
90124 assert str (exc .value ) == "Invalid value for DocumentDetails"
125+
126+
127+ def test_should_fail_with_double_space ():
128+ DATA = "AADHAAR IND ****1234"
129+
130+ with pytest .raises (ValueError ) as exc :
131+ DocumentDetails (DATA )
132+ assert str (exc .value ) == "Invalid value for DocumentDetails"
0 commit comments