Last active
August 29, 2015 14:13
-
-
Save cansadadeserfeliz/f9dc7b342664e4990409 to your computer and use it in GitHub Desktop.
File attachments for Django test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.files.uploadedfile import SimpleUploadedFile | |
class UploadTestCase(TestCase): | |
def test_can_upload_file(self): | |
self.client.logout() | |
self.client.login(username='[email protected]', password='demo') | |
attachment = SimpleUploadedFile('attachment.pdf', 'file_content', content_type='application/pdf') | |
response = self.client.post( | |
reverse( | |
'contract:contract_update', | |
args=(contract.id,) | |
), { | |
'attachment_file': attachment, | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment