mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
complete implementation of dataset SDK (#2147)
### What problem does this PR solve? Complete implementation of dataset SDK. #1102 ### Type of change - [x] New Feature (non-breaking change which adds functionality) --------- Co-authored-by: Feiue <10215101452@stu.ecun.edu.cn> Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
This commit is contained in:
@ -7,7 +7,7 @@ from test_sdkbase import TestSdk
|
||||
class TestDataset(TestSdk):
|
||||
def test_create_dataset_with_success(self):
|
||||
"""
|
||||
Test creating dataset with success
|
||||
Test creating a dataset with success
|
||||
"""
|
||||
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
||||
ds = rag.create_dataset("God")
|
||||
@ -18,15 +18,46 @@ class TestDataset(TestSdk):
|
||||
|
||||
def test_update_dataset_with_success(self):
|
||||
"""
|
||||
Test updating dataset with success.
|
||||
Test updating a dataset with success.
|
||||
"""
|
||||
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
||||
ds = rag.create_dataset("ABC")
|
||||
if isinstance(ds, DataSet):
|
||||
assert ds.name == "ABC", "Name does not match."
|
||||
assert ds.name == "ABC", "Name does not match."
|
||||
ds.name = 'DEF'
|
||||
res = ds.save()
|
||||
assert res is True, f"Failed to update dataset, error: {res}"
|
||||
|
||||
assert res is True, f"Failed to update dataset, error: {res}"
|
||||
else:
|
||||
assert False, f"Failed to create dataset, error: {ds}"
|
||||
assert False, f"Failed to create dataset, error: {ds}"
|
||||
|
||||
def test_delete_dataset_with_success(self):
|
||||
"""
|
||||
Test deleting a dataset with success
|
||||
"""
|
||||
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
||||
ds = rag.create_dataset("MA")
|
||||
if isinstance(ds, DataSet):
|
||||
assert ds.name == "MA", "Name does not match."
|
||||
res = ds.delete()
|
||||
assert res is True, f"Failed to delete dataset, error: {res}"
|
||||
else:
|
||||
assert False, f"Failed to create dataset, error: {ds}"
|
||||
|
||||
def test_list_datasets_with_success(self):
|
||||
"""
|
||||
Test listing datasets with success
|
||||
"""
|
||||
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
||||
list_datasets = rag.list_datasets()
|
||||
assert len(list_datasets) > 0, "Do not exist any dataset"
|
||||
for ds in list_datasets:
|
||||
assert isinstance(ds, DataSet), "Existence type is not dataset."
|
||||
|
||||
def test_get_detail_dataset_with_success(self):
|
||||
"""
|
||||
Test getting a dataset's detail with success
|
||||
"""
|
||||
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
||||
ds = rag.get_dataset(name="God")
|
||||
assert isinstance(ds, DataSet), f"Failed to get dataset, error: {ds}."
|
||||
assert ds.name == "God", "Name does not match"
|
||||
|
||||
Reference in New Issue
Block a user