# Path: gallery/storages.py
# @functools.lru_cache()
# def get_storage(name):
#     name = name.upper()
#     storage_setting = f'GALLERY_{name}_STORAGE'
#     dir_setting = f'GALLERY_{name}_DIR'
#     try:
#         storage_class = getattr(settings, storage_setting)
#     except AttributeError:
#         # There's a good chance that this fallback will survive for a long
#         # time because deprecating it would require updating all the tests.
#         try:
#             storage_dir = getattr(settings, dir_setting)
#         except AttributeError:
#             raise ImproperlyConfigured(
#                 f"Please define {storage_setting} or {dir_setting}")
#         else:
#             return FileSystemStorage(location=storage_dir)
#     else:
#         return import_string(storage_class)()


import io
from django.core.exceptions import ImproperlyConfigured
from django.core.files.storage import FileSystemStorage, Storage
from django.test import TestCase
from django.test.utils import override_settings
from .storages import get_storage

    """
    def path(self, name):
        return '/path/to/' + name


class RemoteStorage(MemoryStorage):
    """
    Emulates a storage class that stores files in memory.

    """
    def url(self, name):
        return '/url/of/' + name


class StoragesTest(TestCase):

    @override_settings(GALLERY_FOO_STORAGE='gallery.test_storages.MemoryStorage')
    def test_get_storage(self):
        foo_storage = get_storage('foo')
        self.assertIsInstance(foo_storage, MemoryStorage)

    @override_settings(GALLERY_FOO_STORAGE='gallery.test_storages.MemoryStorage')
    def test_get_storage_caching(self):
        foo_storage_1 = get_storage('foo')
        foo_storage_2 = get_storage('foo')
        self.assertIs(foo_storage_1, foo_storage_2)

    @override_settings(GALLERY_FOO_DIR='/path/to/foo')
    def test_get_storage_legacy(self):

# Path: gallery/storages.py
# @functools.lru_cache()
# def get_storage(name):
#     name = name.upper()
#     storage_setting = f'GALLERY_{name}_STORAGE'
#     dir_setting = f'GALLERY_{name}_DIR'
#     try:
#         storage_class = getattr(settings, storage_setting)
#     except AttributeError:
#         # There's a good chance that this fallback will survive for a long
#         # time because deprecating it would require updating all the tests.
#         try:
#             storage_dir = getattr(settings, dir_setting)
#         except AttributeError:
#             raise ImproperlyConfigured(
#                 f"Please define {storage_setting} or {dir_setting}")
#         else:
#             return FileSystemStorage(location=storage_dir)
#     else:
#         return import_string(storage_class)()


# Path: gallery/test_storages.py
import io
from django.core.exceptions import ImproperlyConfigured
from django.core.files.storage import FileSystemStorage, Storage
from django.test import TestCase
from django.test.utils import override_settings
from .storages import get_storage


    """
    def path(self, name):
        return '/path/to/' + name


class RemoteStorage(MemoryStorage):
    """
    Emulates a storage class that stores files in memory.

    """
    def url(self, name):
        return '/url/of/' + name


class StoragesTest(TestCase):

    @override_settings(GALLERY_FOO_STORAGE='gallery.test_storages.MemoryStorage')
    def test_get_storage(self):
        foo_storage = get_storage('foo')
        self.assertIsInstance(foo_storage, MemoryStorage)

    @override_settings(GALLERY_FOO_STORAGE='gallery.test_storages.MemoryStorage')
    def test_get_storage_caching(self):
        foo_storage_1 = get_storage('foo')
        foo_storage_2 = get_storage('foo')
        self.assertIs(foo_storage_1, foo_storage_2)

    @override_settings(GALLERY_FOO_DIR='/path/to/foo')
    def test_get_storage_legacy(self):

        foo_storage = get_storage('foo')