923 |
923 |
widget.field = fakefield
|
924 |
924 |
mock_form_submission(req, widget, {'test': '443170139'})
|
925 |
925 |
assert not widget.has_error()
|
|
926 |
assert widget.value == '443170139'
|
|
927 |
|
|
928 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
|
929 |
widget.field = fakefield
|
|
930 |
mock_form_submission(req, widget, {'test': ' 443 170 139'})
|
|
931 |
assert not widget.has_error()
|
|
932 |
assert widget.value == '443170139'
|
926 |
933 |
|
927 |
934 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
928 |
935 |
widget.field = fakefield
|
929 |
936 |
mock_form_submission(req, widget, {'test': '443170130'})
|
930 |
937 |
assert widget.has_error()
|
931 |
938 |
assert widget.error == 'Invalid SIREN code'
|
|
939 |
assert widget.value == '443170130'
|
932 |
940 |
|
933 |
941 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
934 |
942 |
widget.field = fakefield
|
935 |
943 |
mock_form_submission(req, widget, {'test': '44317013900036'})
|
936 |
944 |
assert widget.has_error()
|
|
945 |
assert widget.value == '44317013900036'
|
937 |
946 |
|
938 |
947 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
939 |
948 |
widget.field = fakefield
|
940 |
949 |
mock_form_submission(req, widget, {'test': 'XXX170130'})
|
941 |
950 |
assert widget.has_error()
|
|
951 |
assert widget.value == 'XXX170130'
|
|
952 |
|
|
953 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
|
954 |
widget.field = fakefield
|
|
955 |
mock_form_submission(req, widget, {'test': 'XXX 170 130'})
|
|
956 |
assert widget.has_error()
|
|
957 |
assert widget.value == 'XXX 170 130' # do not normalize invalid value
|
942 |
958 |
|
943 |
959 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
944 |
960 |
widget.field = fakefield
|
945 |
961 |
mock_form_submission(req, widget, {'test': '443170¹39'})
|
946 |
962 |
assert widget.has_error()
|
|
963 |
assert widget.value == '443170¹39'
|
947 |
964 |
|
948 |
965 |
|
949 |
966 |
def test_wcsextrastringwidget_siret_validation():
|
... | ... | |
958 |
975 |
widget.field = fakefield
|
959 |
976 |
mock_form_submission(req, widget, {'test': '44317013900036'})
|
960 |
977 |
assert not widget.has_error()
|
|
978 |
assert widget.value == '44317013900036'
|
961 |
979 |
|
|
980 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
|
981 |
widget.field = fakefield
|
|
982 |
mock_form_submission(req, widget, {'test': '443 170 139 00036'})
|
|
983 |
assert not widget.has_error()
|
|
984 |
assert widget.value == '44317013900036' # normalized
|
|
985 |
|
|
986 |
assert not widget.has_error()
|
962 |
987 |
# special case la poste
|
963 |
988 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
964 |
989 |
widget.field = fakefield
|
965 |
990 |
mock_form_submission(req, widget, {'test': '35600000000048'})
|
966 |
991 |
assert not widget.has_error()
|
|
992 |
assert widget.value == '35600000000048'
|
967 |
993 |
|
968 |
994 |
# failing cases
|
969 |
995 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
... | ... | |
971 |
997 |
mock_form_submission(req, widget, {'test': '44317013900037'})
|
972 |
998 |
assert widget.has_error()
|
973 |
999 |
assert widget.error == 'Invalid SIRET code'
|
|
1000 |
assert widget.value == '44317013900037'
|
974 |
1001 |
|
975 |
1002 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
976 |
1003 |
widget.field = fakefield
|
977 |
1004 |
mock_form_submission(req, widget, {'test': 'ABC17013900037'})
|
978 |
1005 |
assert widget.has_error()
|
|
1006 |
assert widget.value == 'ABC17013900037'
|
979 |
1007 |
|
980 |
1008 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
981 |
1009 |
widget.field = fakefield
|
982 |
1010 |
mock_form_submission(req, widget, {'test': '443170139'})
|
983 |
1011 |
assert widget.has_error()
|
|
1012 |
assert widget.value == '443170139'
|
|
1013 |
|
|
1014 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
|
1015 |
widget.field = fakefield
|
|
1016 |
mock_form_submission(req, widget, {'test': '443 170 139'})
|
|
1017 |
assert widget.has_error()
|
|
1018 |
assert widget.value == '443 170 139' # do not normalize invalid value
|
984 |
1019 |
|
985 |
1020 |
|
986 |
1021 |
def test_wcsextrastringwidget_nir_validation():
|
... | ... | |
996 |
1031 |
# https://fr.wikipedia.org/wiki/Num%C3%A9ro_de_s%C3%A9curit%C3%A9_sociale_en_France#/media/Fichier:CarteVitale2.jpg
|
997 |
1032 |
mock_form_submission(req, widget, {'test': '269054958815780'})
|
998 |
1033 |
assert not widget.has_error()
|
|
1034 |
assert widget.value == '269054958815780'
|
999 |
1035 |
|
1000 |
1036 |
# corsica
|
1001 |
1037 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
1002 |
1038 |
widget.field = fakefield
|
1003 |
1039 |
mock_form_submission(req, widget, {'test': '269052A58815717'})
|
1004 |
1040 |
assert not widget.has_error()
|
|
1041 |
assert widget.value == '269052A58815717'
|
1005 |
1042 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
1006 |
1043 |
widget.field = fakefield
|
1007 |
1044 |
mock_form_submission(req, widget, {'test': '269052B58815744'})
|
1008 |
1045 |
assert not widget.has_error()
|
|
1046 |
assert widget.value == '269052B58815744'
|
|
1047 |
|
|
1048 |
# accept spaces, but remove them
|
|
1049 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
|
1050 |
widget.field = fakefield
|
|
1051 |
mock_form_submission(req, widget, {'test': '2 69 05 2B588 157 44'})
|
|
1052 |
assert not widget.has_error()
|
|
1053 |
assert widget.value == '269052B58815744'
|
1009 |
1054 |
|
1010 |
1055 |
# failing cases
|
1011 |
1056 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
... | ... | |
1013 |
1058 |
mock_form_submission(req, widget, {'test': '42'})
|
1014 |
1059 |
assert widget.has_error()
|
1015 |
1060 |
assert widget.error == 'Invalid NIR'
|
|
1061 |
assert widget.value == '42'
|
1016 |
1062 |
|
1017 |
1063 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
1018 |
1064 |
widget.field = fakefield
|
1019 |
1065 |
mock_form_submission(req, widget, {'test': '269054958815700'})
|
1020 |
1066 |
assert widget.has_error()
|
|
1067 |
assert widget.value == '269054958815700'
|
1021 |
1068 |
|
1022 |
1069 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
1023 |
1070 |
widget.field = fakefield
|
1024 |
1071 |
mock_form_submission(req, widget, {'test': 'hello 789012345'})
|
1025 |
1072 |
assert widget.has_error()
|
|
1073 |
assert widget.value == 'hello 789012345'
|
1026 |
1074 |
|
1027 |
1075 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
1028 |
1076 |
widget.field = fakefield
|
1029 |
1077 |
mock_form_submission(req, widget, {'test': '069054958815780'})
|
1030 |
1078 |
assert widget.has_error()
|
|
1079 |
assert widget.value == '069054958815780'
|
1031 |
1080 |
|
1032 |
1081 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
1033 |
1082 |
widget.field = fakefield
|
1034 |
1083 |
mock_form_submission(req, widget, {'test': '269004958815780'})
|
1035 |
1084 |
assert widget.has_error()
|
|
1085 |
assert widget.value == '269004958815780'
|
1036 |
1086 |
|
1037 |
1087 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
1038 |
1088 |
widget.field = fakefield
|
1039 |
1089 |
mock_form_submission(req, widget, {'test': '269054900015780'})
|
1040 |
1090 |
assert widget.has_error()
|
|
1091 |
assert widget.value == '269054900015780'
|
1041 |
1092 |
|
1042 |
1093 |
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
1043 |
1094 |
widget.field = fakefield
|
1044 |
1095 |
mock_form_submission(req, widget, {'test': '269054958800080'})
|
1045 |
1096 |
assert widget.has_error()
|
|
1097 |
assert widget.value == '269054958800080'
|
1046 |
1098 |
|
1047 |
1099 |
|
1048 |
1100 |
def test_wcsextrastringwidget_belgian_nrn_validation():
|