| | 205 | Test for the behavior of _has_changed for FileInput. The value of data will |
|---|
| | 206 | more than likely come from request.FILES. The value of initial data will |
|---|
| | 207 | likely be a filename stored in the database. Since its value is of no use to |
|---|
| | 208 | a FileInput it is ignored. |
|---|
| | 209 | |
|---|
| | 210 | >>> w = FileInput() |
|---|
| | 211 | |
|---|
| | 212 | # No file was uploaded and no initial data. |
|---|
| | 213 | >>> w._has_changed(None, '') |
|---|
| | 214 | False |
|---|
| | 215 | |
|---|
| | 216 | # TODO: need to think about this case some more. |
|---|
| | 217 | >>> w._has_changed({}, '') |
|---|
| | 218 | False |
|---|
| | 219 | |
|---|
| | 220 | # A file was uploaded and no initial data. |
|---|
| | 221 | >>> w._has_changed({'filename': 'resume.txt', 'content': 'My resume'}, '') |
|---|
| | 222 | True |
|---|
| | 223 | |
|---|
| | 224 | # A file was not uploaded, but there is initial data |
|---|
| | 225 | >>> w._has_changed(None, 'resume.txt') |
|---|
| | 226 | False |
|---|
| | 227 | |
|---|
| | 228 | # A file was uploaded and there is initial data (file identity is not dealt |
|---|
| | 229 | # with here) |
|---|
| | 230 | >>> w._has_changed({'filename': 'resume.txt', 'content': 'My resume'}, 'resume.txt') |
|---|
| | 231 | True |
|---|
| | 232 | |
|---|