Opened 10 years ago

Closed 10 years ago

#24330 closed New feature (needsinfo)

Test suites for modular components - storage class, cache backends.

Reported by: georgewhewell Owned by: nobody
Component: Testing framework Version: 1.7
Severity: Normal Keywords: testing, storage
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When implementing a custom storage class, there seems to be no way to confirm that it is behaving as expected by django. It would be useful to have a test suite that only used the interface provided by the DEFAULT_FILE_STORAGE class and checked things like saving and reading a file returns the same content, seeking, .url method. As not all methods appear mandatory, these could be skipped for backends which don't implement them.

For example, the django-storages package's documentation for FTP backend[1] reads:

This implementation was done preliminary for upload files in admin to remote FTP location and read them back on site by HTTP. It was tested mostly in this configuration, so read/write using FTPStorageFile class may break.

It would be nice to be able to run the same tests against this backend by overriding the DEFAULT_FILE_STORAGE setting to determine if it will break or not.

[1] https://django-storages.readthedocs.org/en/latest/backends/ftp.html

Change History (1)

comment:1 by Tim Graham, 10 years ago

Resolution: needsinfo
Status: newclosed

Have you tried running Django's test suite and overriding DEFAULT_FILE_STORAGE with the storage you want to test? I guess the end result might look similar to how we have features flags on the database backend API so that we can skip tests that don't implement certain things. I'm going to close this ticket as it seems too broad and not actionable without further research. If you are interested in tackling it, I'd suggest to write to the DevelopersMailingList to get feedback on your proposal.

Note: See TracTickets for help on using tickets.
Back to Top