I have the following code, which I need to test:
uploader = AjaxFileUploader(backend=XLSXFileUploadBackend, obj=obj)
response = uploader(request)
...
response.content
I'd like to mock AjaxFileUploader and replace the response.content with some value.
I do the following:
@patch('guinness.apps.home.views.AjaxFileUploader')
def test_import_asset_to_bucket(self, mock_file_uploader):
test_content = 'a:"1"'
mock_file_uploader.return_value = MagicMock(return_value=MagicMock(content=test_content))
Is there more elegant way to do it? Thanks!