#11159 closed (fixed)
Test client encode_file doesn't set content-type properly
Reported by: | notanumber | Owned by: | notanumber |
---|---|---|---|
Component: | Testing framework | Version: | 1.0 |
Severity: | Keywords: | encode_file content-type | |
Cc: | varikin@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The test client doesn't properly set the content-type when uploading files. It hard-codes the content-type value to to 'application/octet-stream'. This makes it difficult to test that code that relies on a specific content-type being set.
The encode_file method could be easily changed to make use of mimetypes.guess_type to make a best guess attempt to set a content-type, falling back to the default 'application/octet-stream'.
I've attached a patch that does this.
Attachments (3)
Change History (11)
by , 16 years ago
Attachment: | test-client-content-type.diff added |
---|
comment:1 by , 15 years ago
Triage Stage: | Unreviewed → Ready for checkin |
---|
comment:2 by , 15 years ago
Cc: | added |
---|
I am using this patch so I can test my form that takes a zip file. I have a clean method that validates the content type and application/octet-stream is valid type for me.
comment:3 by , 15 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 15 years ago
Needs tests: | set |
---|
by , 14 years ago
Attachment: | test_client_test.diff added |
---|
Test of encode_file(). Documents current and desired behavior.
comment:5 by , 14 years ago
Needs tests: | unset |
---|
comment:7 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Test client patch to add content-type in encode_file function