Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/test_api_client.py
# Copyright (C) 2015-2020 The Software Heritage developers | # Copyright (C) 2015-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from unittest.mock import patch | from unittest.mock import patch | ||||
import pytest | import pytest | ||||
import swh.storage.api.server as server | import swh.storage.api.server as server | ||||
import swh.storage.storage | import swh.storage.storage | ||||
from swh.storage import get_storage | from swh.storage import get_storage | ||||
from swh.storage.tests.test_storage import TestStorageGeneratedData # noqa | from swh.storage.tests.test_storage import TestStorageGeneratedData # noqa | ||||
from swh.storage.tests.test_storage import TestStorage as _TestStorage | from swh.storage.tests.test_storage import TestStorage as _TestStorage | ||||
from swh.storage.tests.conftest import BWCompatInMemoryJournalWriter | |||||
# tests are executed using imported classes (TestStorage and | # tests are executed using imported classes (TestStorage and | ||||
# TestStorageGeneratedData) using overloaded swh_storage fixture | # TestStorageGeneratedData) using overloaded swh_storage fixture | ||||
# below | # below | ||||
@pytest.fixture | @pytest.fixture | ||||
def app_server(): | def app_server(): | ||||
storage_config = { | storage_config = { | ||||
"cls": "memory", | "cls": "memory", | ||||
"journal_writer": {"cls": "memory",}, | "journal_writer": {"cls": "memory",}, | ||||
} | } | ||||
with patch( | |||||
"swh.journal.writer.inmemory.InMemoryJournalWriter", | |||||
return_value=BWCompatInMemoryJournalWriter(), | |||||
): | |||||
server.storage = swh.storage.get_storage(**storage_config) | server.storage = swh.storage.get_storage(**storage_config) | ||||
yield server | yield server | ||||
@pytest.fixture | @pytest.fixture | ||||
def app(app_server): | def app(app_server): | ||||
return app_server.app | return app_server.app | ||||
Show All 34 Lines |