mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Add test for API (#3134)
### What problem does this PR solve? Add test for API ### Type of change - [x] New Feature (non-breaking change which adds functionality) --------- Co-authored-by: liuhua <10215101452@stu.ecun.edu.cn> Co-authored-by: Zhichang Yu <yuzhichang@gmail.com>
This commit is contained in:
@ -1,9 +1,7 @@
|
||||
import os
|
||||
from ragflow_sdk import RAGFlow
|
||||
import random
|
||||
import pytest
|
||||
from ragflow_sdk import RAGFlow
|
||||
|
||||
HOST_ADDRESS = os.getenv('HOST_ADDRESS', 'http://127.0.0.1:9380')
|
||||
from common import HOST_ADDRESS
|
||||
|
||||
def test_create_dataset_with_name(get_api_key_fixture):
|
||||
API_KEY = get_api_key_fixture
|
||||
@ -13,8 +11,9 @@ def test_create_dataset_with_name(get_api_key_fixture):
|
||||
def test_create_dataset_with_duplicated_name(get_api_key_fixture):
|
||||
API_KEY = get_api_key_fixture
|
||||
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
||||
rag.create_dataset("test_create_dataset_with_duplicated_name")
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
rag.create_dataset("test_create_dataset_with_name")
|
||||
rag.create_dataset("test_create_dataset_with_duplicated_name")
|
||||
assert str(exc_info.value) == "Duplicated dataset name in creating dataset."
|
||||
|
||||
def test_create_dataset_with_random_chunk_method(get_api_key_fixture):
|
||||
@ -31,7 +30,7 @@ def test_create_dataset_with_invalid_parameter(get_api_key_fixture):
|
||||
"knowledge_graph", "email"]
|
||||
chunk_method = "invalid_chunk_method"
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
rag.create_dataset("test_create_dataset_with_name",chunk_method=chunk_method)
|
||||
rag.create_dataset("test_create_dataset_with_invalid_chunk_method",chunk_method=chunk_method)
|
||||
assert str(exc_info.value) == f"'{chunk_method}' is not in {valid_chunk_methods}"
|
||||
|
||||
|
||||
@ -45,7 +44,7 @@ def test_update_dataset_with_name(get_api_key_fixture):
|
||||
def test_delete_datasets_with_success(get_api_key_fixture):
|
||||
API_KEY = get_api_key_fixture
|
||||
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
||||
ds = rag.create_dataset("MA")
|
||||
ds = rag.create_dataset("test_delete_dataset")
|
||||
rag.delete_datasets(ids=[ds.id])
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user