summaryrefslogtreecommitdiff
path: root/tests/regressiontests/forms/widgets.py
diff options
context:
space:
mode:
authorBrian Rosner <brosner@gmail.com>2008-04-29 04:31:59 +0000
committerBrian Rosner <brosner@gmail.com>2008-04-29 04:31:59 +0000
commit95dcdf473ed08f03040334d716c4e60c2a41e57c (patch)
tree72e4ee8f5513bd0735d07d60c4ed65314bb2b60a /tests/regressiontests/forms/widgets.py
parentc9c714f0f89170ab43b9bb6e5c0ea1f3183301de (diff)
newforms-admin: Fixed #6964 -- Implemented FileInput._has_changed. Before it was comparing the wrong values and causing it to trip up.
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7506 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/forms/widgets.py')
-rw-r--r--tests/regressiontests/forms/widgets.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/regressiontests/forms/widgets.py b/tests/regressiontests/forms/widgets.py
index 493cfa053c..4944a26b74 100644
--- a/tests/regressiontests/forms/widgets.py
+++ b/tests/regressiontests/forms/widgets.py
@@ -202,6 +202,30 @@ u'<input type="file" class="fun" name="email" />'
>>> w.render('email', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'})
u'<input type="file" class="fun" name="email" />'
+Test for the behavior of _has_changed for FileInput. The value of data will
+more than likely come from request.FILES. The value of initial data will
+likely be a filename stored in the database. Since its value is of no use to
+a FileInput it is ignored.
+
+>>> w = FileInput()
+
+# No file was uploaded and no initial data.
+>>> w._has_changed(u'', None)
+False
+
+# A file was uploaded and no initial data.
+>>> w._has_changed(u'', {'filename': 'resume.txt', 'content': 'My resume'})
+True
+
+# A file was not uploaded, but there is initial data
+>>> w._has_changed(u'resume.txt', None)
+False
+
+# A file was uploaded and there is initial data (file identity is not dealt
+# with here)
+>>> w._has_changed('resume.txt', {'filename': 'resume.txt', 'content': 'My resume'})
+True
+
# Textarea Widget #############################################################
>>> w = Textarea()