jazzband / django-downloadview

Serve files with Django.
https://django-downloadview.readthedocs.io
Other
380 stars 58 forks source link

Avoid calling PathDownloadView.get_path() twice inside get_file() #103

Closed rleonhardt closed 9 years ago

rleonhardt commented 9 years ago

Overridden PathDownloadView.get_path() may contain database lookups and logging which should not be called twice if not necessary, as it was in my case. Because the acquired filename does not change inside get_file(), I replaced the duplicate call.

benoitbryon commented 9 years ago

Agreed! get_path() should be called only once.

I haven't figured out yet why the tests fail. The fails seem unrelated to your changes...

benoitbryon commented 9 years ago

Planned this fix for next release :)

rleonhardt commented 9 years ago

I assume my small change has nothing to do with this, maybe a hidden test problem is showing up? Those are the only 2 cases where assertCalledOnceWith() is being called, otherwise I can only find usages of assert_called_once_with() from mock.py::228

funcopy.assert_called_once_with = assert_called_once_with

Great, thanks, I'm looking forward to it! :)

rleonhardt commented 9 years ago

I changed the tests according to the failure messages, and travis succeeded, please review.

benoitbryon commented 9 years ago

Merged and released! Thank you @rleonhardt :)