Skip to content

test_file_storage#

file_storage_settings#

Source code in tests/unit/apps/files/models/test_file_storage.py
@pytest.fixture(autouse=True)
def file_storage_settings(settings):
    settings.STORAGE_SERVICE_FILE_STORAGES.clear()
    settings.STORAGE_SERVICE_FILE_STORAGES.update(
        {
            "basic": "BasicFileStorage",
            "csc_project": "ProjectFileStorage",
            "ida": "IDAFileStorage",
        }
    )

test_create_file_storage_basic#

Source code in tests/unit/apps/files/models/test_file_storage.py
def test_create_file_storage_basic():
    storage = FileStorage.objects.create(storage_service="basic")
    assert type(storage) == BasicFileStorage

test_create_file_storage_basic_with_project#

Source code in tests/unit/apps/files/models/test_file_storage.py
def test_create_file_storage_basic_with_project():
    with pytest.raises(ValueError):
        FileStorage.objects.create(storage_service="basic", csc_project="x")

test_create_file_storage_project#

Source code in tests/unit/apps/files/models/test_file_storage.py
def test_create_file_storage_project():
    storage = FileStorage.objects.create(storage_service="csc_project", csc_project="x")
    assert type(storage) == ProjectFileStorage

test_create_file_storage_project_without_project#

Source code in tests/unit/apps/files/models/test_file_storage.py
def test_create_file_storage_project_without_project():
    with pytest.raises(ValueError):
        FileStorage.objects.create(storage_service="csc_project")

test_create_file_storage_ida#

Source code in tests/unit/apps/files/models/test_file_storage.py
def test_create_file_storage_ida():
    storage = FileStorage.objects.create(storage_service="ida", csc_project="x")
    assert type(storage) == IDAFileStorage

test_create_file_storage_ida_without_project#

Source code in tests/unit/apps/files/models/test_file_storage.py
def test_create_file_storage_ida_without_project():
    with pytest.raises(ValueError):
        FileStorage.objects.create(storage_service="ida")

multiple_file_storages#

Source code in tests/unit/apps/files/models/test_file_storage.py
@pytest.fixture
def multiple_file_storages():
    FileStorage.objects.create(storage_service="ida", csc_project="x")
    FileStorage.objects.create(storage_service="ida", csc_project="y")
    FileStorage.objects.create(storage_service="csc_project", csc_project="x")
    FileStorage.objects.create(storage_service="basic")

test_file_storages_list_all#

Source code in tests/unit/apps/files/models/test_file_storage.py
@pytest.mark.django_db
def test_file_storages_list_all(multiple_file_storages):
    assert FileStorage.objects.count() == 4

test_file_storages_list_basic#

Source code in tests/unit/apps/files/models/test_file_storage.py
@pytest.mark.django_db
def test_file_storages_list_basic(multiple_file_storages):
    assert BasicFileStorage.objects.count() == 1

test_file_storages_list_project#

Source code in tests/unit/apps/files/models/test_file_storage.py
@pytest.mark.django_db
def test_file_storages_list_project(multiple_file_storages):
    assert ProjectFileStorage.objects.count() == 3  # counts also IDAFileStorages

test_file_storages_list_ida#

Source code in tests/unit/apps/files/models/test_file_storage.py
@pytest.mark.django_db
def test_file_storages_list_ida(multiple_file_storages):
    assert IDAFileStorage.objects.count() == 2