Commit a6c00a4 1 parent fb6d850 commit a6c00a4 Copy full SHA for a6c00a4
File tree 2 files changed +46
-0
lines changed
2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 3
3
from ..migration_converters import (
4
4
ensure_licensplate_validate_pattern ,
5
5
ensure_postcode_validate_pattern ,
6
+ prevent_datetime_components_from_emptying_invalid_values ,
6
7
)
7
8
from ..typing import Component
8
9
@@ -35,3 +36,16 @@ def test_noop(self):
35
36
changed = ensure_postcode_validate_pattern (component )
36
37
37
38
self .assertFalse (changed )
39
+
40
+
41
+ class DatetimeTests (SimpleTestCase ):
42
+ def test_update (self ):
43
+ component : Component = {
44
+ "type" : "datetime" ,
45
+ "key" : "datetime" ,
46
+ }
47
+
48
+ changed = prevent_datetime_components_from_emptying_invalid_values (component )
49
+
50
+ self .assertTrue (changed )
51
+ self .assertTrue (component ["customOptions" ]["allowInvalidPreload" ])
Original file line number Diff line number Diff line change @@ -911,3 +911,35 @@ def test_postcode_validate_added(self):
911
911
postcode ["validate" ]["pattern" ],
912
912
r"^[1-9][0-9]{3} ?(?!sa|sd|ss|SA|SD|SS)[a-zA-Z]{2}$" ,
913
913
)
914
+
915
+
916
+ class DatetimeAllowInvalidInputTests (TestMigrations ):
917
+ app = "forms"
918
+ migrate_from = "0103_fix_component_problems"
919
+ migrate_to = "0104_allow_invalid_input_datetime"
920
+
921
+ def setUpBeforeMigration (self , apps ):
922
+ FormDefinition = apps .get_model ("forms" , "FormDefinition" )
923
+
924
+ self .form_definition = FormDefinition .objects .create (
925
+ name = "Datetime" ,
926
+ slug = "datetime" ,
927
+ configuration = {
928
+ "components" : [
929
+ {"key" : "datetime" , "type" : "datetime" },
930
+ {"key" : "time" , "type" : "time" },
931
+ ]
932
+ },
933
+ )
934
+
935
+ def test_datetime_component_modified (self ):
936
+ self .form_definition .refresh_from_db ()
937
+
938
+ self .assertTrue (
939
+ self .form_definition .configuration ["components" ][0 ]["customOptions" ][
940
+ "allowInvalidPreload"
941
+ ]
942
+ )
943
+ self .assertNotIn (
944
+ "customOptions" , self .form_definition .configuration ["components" ][1 ]
945
+ )
You can’t perform that action at this time.
0 commit comments