override_settings does not work for S3BotoStorage

Issue #226 new
Gianluca Pacchiella
created an issue

In S3BotoStorage the various configurations are read at initialization time

class S3BotoStorage(Storage):
    ...
    file_overwrite = setting('AWS_S3_FILE_OVERWRITE', True)
    ...

because of this I cannot unit test the behaviour of my django site using for example moto and a class like

@mock_s3
@override_settings(
    AWS_ACCESS_KEY_ID='bau',
    AWS_SECRET_ACCESS_KEY='miao',
    AWS_STORAGE_BUCKET_NAME='bucket',
    AWS_CLOUDFRONT_DOMAIN='foobar',
    AWS_CLOUDFRONT_DISTRIBUTION_ID='kebba',
    AWS_S3_FILE_OVERWRITE=False,
)
class ApiTests(BaseAPITestCase):
   ...

since override_settings has not effect (i.e. the settings are already read); all is working fine if these values are read directly from django.conf.settings:

class S3BotoStorage(Storage):
    ...
    @property
    def file_overwrite(self):
        from django.conf import settings
        return getattr(settings, 'AWS_S3_FILE_OVERWRITE', True)
    ...