mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-09 02:46:52 +08:00
feat: integrate opendal storage (#11508)
Signed-off-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
@@ -6,7 +6,7 @@ from extensions.storage.base_storage import BaseStorage
|
||||
|
||||
|
||||
def get_example_folder() -> str:
|
||||
return "/dify"
|
||||
return "~/dify"
|
||||
|
||||
|
||||
def get_example_bucket() -> str:
|
||||
@@ -22,14 +22,14 @@ def get_example_data() -> bytes:
|
||||
|
||||
|
||||
def get_example_filepath() -> str:
|
||||
return "/test"
|
||||
return "~/test"
|
||||
|
||||
|
||||
class BaseStorageTest:
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_method(self):
|
||||
def setup_method(self, *args, **kwargs):
|
||||
"""Should be implemented in child classes to setup specific storage."""
|
||||
self.storage = BaseStorage()
|
||||
self.storage: BaseStorage
|
||||
|
||||
def test_save(self):
|
||||
"""Test saving data."""
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
from collections.abc import Generator
|
||||
|
||||
import pytest
|
||||
|
||||
from extensions.storage.local_fs_storage import LocalFsStorage
|
||||
from tests.unit_tests.oss.__mock.base import (
|
||||
BaseStorageTest,
|
||||
get_example_folder,
|
||||
)
|
||||
from tests.unit_tests.oss.__mock.local import setup_local_fs_mock
|
||||
|
||||
|
||||
class TestLocalFS(BaseStorageTest):
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_method(self, setup_local_fs_mock):
|
||||
"""Executed before each test method."""
|
||||
self.storage = LocalFsStorage()
|
||||
self.storage.folder = get_example_folder()
|
||||
19
api/tests/unit_tests/oss/opendal/test_opendal.py
Normal file
19
api/tests/unit_tests/oss/opendal/test_opendal.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import pytest
|
||||
|
||||
from configs.middleware.storage.opendal_storage_config import OpenDALScheme
|
||||
from extensions.storage.opendal_storage import OpenDALStorage
|
||||
from tests.unit_tests.oss.__mock.base import (
|
||||
BaseStorageTest,
|
||||
get_example_folder,
|
||||
)
|
||||
from tests.unit_tests.oss.__mock.local import setup_local_fs_mock
|
||||
|
||||
|
||||
class TestOpenDAL(BaseStorageTest):
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_method(self, *args, **kwargs):
|
||||
"""Executed before each test method."""
|
||||
self.storage = OpenDALStorage(
|
||||
scheme=OpenDALScheme.FS,
|
||||
root=get_example_folder(),
|
||||
)
|
||||
Reference in New Issue
Block a user