@@ -645,3 +645,59 @@ def test_non_strict_field(self):
645645 self .enum_primitive ("non_strict_int" ),
646646 )
647647 self .assertEqual (form ["non_strict_int" ].value (), [200 , 203 ])
648+
649+ def test_has_changed (self ):
650+ {
651+ "small_pos_int" : [0 ],
652+ "small_int" : [self .SmallIntEnum .VAL2 , self .SmallIntEnum .VALn1 ],
653+ "pos_int" : [2147483647 , self .PosIntEnum .VAL3 ],
654+ "int" : [self .IntEnum .VALn1 ],
655+ "big_pos_int" : [2 , self .BigPosIntEnum .VAL3 ],
656+ "big_int" : [self .BigIntEnum .VAL0 ],
657+ "constant" : [2.71828 , self .Constants .GOLDEN_RATIO ],
658+ "text" : [self .TextEnum .VALUE3 , self .TextEnum .VALUE2 ],
659+ "extern" : [self .ExternEnum .THREE ],
660+ "date_enum" : [self .DateEnum .BRIAN , date (1989 , 7 , 27 )],
661+ "datetime_enum" : [self .DateTimeEnum .ST_HELENS , self .DateTimeEnum .ST_HELENS ],
662+ "duration_enum" : [self .DurationEnum .FORTNIGHT ],
663+ "time_enum" : [self .TimeEnum .COB , self .TimeEnum .LUNCH ],
664+ "decimal_enum" : [self .DecimalEnum .ONE ],
665+ "non_strict_int" : [self .SmallPosIntEnum .VAL2 ],
666+ "non_strict_text" : ["arbitrary" , "A" * 13 ],
667+ "no_coerce" : [self .SmallPosIntEnum .VAL1 ],
668+ }
669+ form = self .FORM_CLASS (
670+ data = {"small_pos_int" : [self .SmallPosIntEnum .VAL1 ]},
671+ initial = {"small_pos_int" : [0 ]},
672+ )
673+ self .assertFalse (form .has_changed ())
674+
675+ form = self .FORM_CLASS (
676+ data = {"small_pos_int" : [self .SmallPosIntEnum .VAL2 ]},
677+ initial = {"small_pos_int" : [0 ]},
678+ )
679+ self .assertTrue (form .has_changed ())
680+
681+ form = self .FORM_CLASS (
682+ data = {"small_pos_int" : [self .SmallPosIntEnum .VAL1 .value ]},
683+ initial = {"small_pos_int" : [self .SmallPosIntEnum .VAL1 ]},
684+ )
685+ self .assertFalse (form .has_changed ())
686+
687+ form = self .FORM_CLASS (
688+ data = {"small_pos_int" : [self .SmallPosIntEnum .VAL2 .value ]},
689+ initial = {"small_pos_int" : [self .SmallPosIntEnum .VAL1 ]},
690+ )
691+ self .assertTrue (form .has_changed ())
692+
693+ form = self .FORM_CLASS (
694+ data = {"small_pos_int" : [str (self .SmallPosIntEnum .VAL1 .value )]},
695+ initial = {"small_pos_int" : [self .SmallPosIntEnum .VAL1 ]},
696+ )
697+ self .assertFalse (form .has_changed ())
698+
699+ form = self .FORM_CLASS (
700+ data = {"small_pos_int" : [str (self .SmallPosIntEnum .VAL2 .value )]},
701+ initial = {"small_pos_int" : [self .SmallPosIntEnum .VAL1 ]},
702+ )
703+ self .assertTrue (form .has_changed ())
0 commit comments