mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-21 13:32:49 +08:00
Fix IDE warnings (#12010)
### What problem does this PR solve? As title ### Type of change - [x] Refactoring Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
@ -38,9 +38,9 @@ class TestAuthorization:
|
||||
)
|
||||
def test_auth_invalid(self, invalid_auth, expected_message):
|
||||
client = RAGFlow(invalid_auth, HOST_ADDRESS)
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.create_dataset(**{"name": "auth_test"})
|
||||
assert str(excinfo.value) == expected_message
|
||||
assert str(exception_info.value) == expected_message
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("clear_datasets")
|
||||
@ -85,9 +85,9 @@ class TestDatasetCreate:
|
||||
ids=["empty_name", "space_name", "too_long_name", "invalid_name", "None_name"],
|
||||
)
|
||||
def test_name_invalid(self, client, name, expected_message):
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.create_dataset(**{"name": name})
|
||||
assert expected_message in str(excinfo.value), str(excinfo.value)
|
||||
assert expected_message in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_name_duplicated(self, client):
|
||||
@ -120,9 +120,9 @@ class TestDatasetCreate:
|
||||
@pytest.mark.p2
|
||||
def test_avatar_exceeds_limit_length(self, client):
|
||||
payload = {"name": "avatar_exceeds_limit_length", "avatar": "a" * 65536}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.create_dataset(**payload)
|
||||
assert "String should have at most 65535 characters" in str(excinfo.value), str(excinfo.value)
|
||||
assert "String should have at most 65535 characters" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p3
|
||||
@pytest.mark.parametrize(
|
||||
@ -141,9 +141,9 @@ class TestDatasetCreate:
|
||||
"name": name,
|
||||
"avatar": f"{prefix}{encode_avatar(fn)}",
|
||||
}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.create_dataset(**payload)
|
||||
assert expected_message in str(excinfo.value), str(excinfo.value)
|
||||
assert expected_message in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_avatar_unset(self, client):
|
||||
@ -160,9 +160,9 @@ class TestDatasetCreate:
|
||||
@pytest.mark.p2
|
||||
def test_description_exceeds_limit_length(self, client):
|
||||
payload = {"name": "description_exceeds_limit_length", "description": "a" * 65536}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.create_dataset(**payload)
|
||||
assert "String should have at most 65535 characters" in str(excinfo.value), str(excinfo.value)
|
||||
assert "String should have at most 65535 characters" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_description_unset(self, client):
|
||||
@ -203,12 +203,12 @@ class TestDatasetCreate:
|
||||
)
|
||||
def test_embedding_model_invalid(self, client, name, embedding_model):
|
||||
payload = {"name": name, "embedding_model": embedding_model}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.create_dataset(**payload)
|
||||
if "tenant_no_auth" in name:
|
||||
assert str(excinfo.value) == f"Unauthorized model: <{embedding_model}>", str(excinfo.value)
|
||||
assert str(exception_info.value) == f"Unauthorized model: <{embedding_model}>", str(exception_info.value)
|
||||
else:
|
||||
assert str(excinfo.value) == f"Unsupported model: <{embedding_model}>", str(excinfo.value)
|
||||
assert str(exception_info.value) == f"Unsupported model: <{embedding_model}>", str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
@pytest.mark.parametrize(
|
||||
@ -226,12 +226,12 @@ class TestDatasetCreate:
|
||||
)
|
||||
def test_embedding_model_format(self, client, name, embedding_model):
|
||||
payload = {"name": name, "embedding_model": embedding_model}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.create_dataset(**payload)
|
||||
if name in ["empty", "space", "missing_at"]:
|
||||
assert "Embedding model identifier must follow <model_name>@<provider> format" in str(excinfo.value), str(excinfo.value)
|
||||
assert "Embedding model identifier must follow <model_name>@<provider> format" in str(exception_info.value), str(exception_info.value)
|
||||
else:
|
||||
assert "Both model_name and provider must be non-empty strings" in str(excinfo.value), str(excinfo.value)
|
||||
assert "Both model_name and provider must be non-empty strings" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
def test_embedding_model_unset(self, client):
|
||||
@ -273,9 +273,9 @@ class TestDatasetCreate:
|
||||
)
|
||||
def test_permission_invalid(self, client, name, permission):
|
||||
payload = {"name": name, "permission": permission}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.create_dataset(**payload)
|
||||
assert "Input should be 'me' or 'team'" in str(excinfo.value)
|
||||
assert "Input should be 'me' or 'team'" in str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
def test_permission_unset(self, client):
|
||||
@ -286,9 +286,9 @@ class TestDatasetCreate:
|
||||
@pytest.mark.p3
|
||||
def test_permission_none(self, client):
|
||||
payload = {"name": "permission_none", "permission": None}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.create_dataset(**payload)
|
||||
assert "not instance of" in str(excinfo.value), str(excinfo.value)
|
||||
assert "not instance of" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p1
|
||||
@pytest.mark.parametrize(
|
||||
@ -325,9 +325,9 @@ class TestDatasetCreate:
|
||||
)
|
||||
def test_chunk_method_invalid(self, client, name, chunk_method):
|
||||
payload = {"name": name, "chunk_method": chunk_method}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.create_dataset(**payload)
|
||||
assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" in str(excinfo.value), str(excinfo.value)
|
||||
assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
def test_chunk_method_unset(self, client):
|
||||
@ -338,9 +338,9 @@ class TestDatasetCreate:
|
||||
@pytest.mark.p3
|
||||
def test_chunk_method_none(self, client):
|
||||
payload = {"name": "chunk_method_none", "chunk_method": None}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.create_dataset(**payload)
|
||||
assert "not instance of" in str(excinfo.value), str(excinfo.value)
|
||||
assert "not instance of" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p1
|
||||
@pytest.mark.parametrize(
|
||||
@ -576,9 +576,9 @@ class TestDatasetCreate:
|
||||
def test_parser_config_invalid(self, client, name, parser_config, expected_message):
|
||||
parser_config_o = DataSet.ParserConfig(client, parser_config)
|
||||
payload = {"name": name, "parser_config": parser_config_o}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.create_dataset(**payload)
|
||||
assert expected_message in str(excinfo.value), str(excinfo.value)
|
||||
assert expected_message in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
def test_parser_config_empty(self, client):
|
||||
@ -631,9 +631,9 @@ class TestDatasetCreate:
|
||||
],
|
||||
)
|
||||
def test_unsupported_field(self, client, payload):
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.create_dataset(**payload)
|
||||
assert "got an unexpected keyword argument" in str(excinfo.value), str(excinfo.value)
|
||||
assert "got an unexpected keyword argument" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("clear_datasets")
|
||||
|
||||
@ -33,9 +33,9 @@ class TestAuthorization:
|
||||
)
|
||||
def test_auth_invalid(self, invalid_auth, expected_message):
|
||||
client = RAGFlow(invalid_auth, HOST_ADDRESS)
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.delete_datasets()
|
||||
assert str(excinfo.value) == expected_message
|
||||
assert str(exception_info.value) == expected_message
|
||||
|
||||
|
||||
class TestCapability:
|
||||
@ -71,6 +71,7 @@ class TestDatasetsDelete:
|
||||
ids=["single_dataset", "multiple_datasets"],
|
||||
)
|
||||
def test_ids(self, client, add_datasets_func, func, remaining):
|
||||
payload = None
|
||||
if callable(func):
|
||||
payload = func([dataset.id for dataset in add_datasets_func])
|
||||
client.delete_datasets(**payload)
|
||||
@ -100,9 +101,9 @@ class TestDatasetsDelete:
|
||||
@pytest.mark.usefixtures("add_dataset_func")
|
||||
def test_id_not_uuid(self, client):
|
||||
payload = {"ids": ["not_uuid"]}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.delete_datasets(**payload)
|
||||
assert "Invalid UUID1 format" in str(excinfo.value), str(excinfo.value)
|
||||
assert "Invalid UUID1 format" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
datasets = client.list_datasets()
|
||||
assert len(datasets) == 1, str(datasets)
|
||||
@ -111,17 +112,17 @@ class TestDatasetsDelete:
|
||||
@pytest.mark.usefixtures("add_dataset_func")
|
||||
def test_id_not_uuid1(self, client):
|
||||
payload = {"ids": [uuid.uuid4().hex]}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.delete_datasets(**payload)
|
||||
assert "Invalid UUID1 format" in str(excinfo.value), str(excinfo.value)
|
||||
assert "Invalid UUID1 format" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
@pytest.mark.usefixtures("add_dataset_func")
|
||||
def test_id_wrong_uuid(self, client):
|
||||
payload = {"ids": ["d94a8dc02c9711f0930f7fbc369eab6d"]}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.delete_datasets(**payload)
|
||||
assert "lacks permission for dataset" in str(excinfo.value), str(excinfo.value)
|
||||
assert "lacks permission for dataset" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
datasets = client.list_datasets()
|
||||
assert len(datasets) == 1, str(datasets)
|
||||
@ -138,9 +139,9 @@ class TestDatasetsDelete:
|
||||
def test_ids_partial_invalid(self, client, add_datasets_func, func):
|
||||
if callable(func):
|
||||
payload = func([dataset.id for dataset in add_datasets_func])
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.delete_datasets(**payload)
|
||||
assert "lacks permission for dataset" in str(excinfo.value), str(excinfo.value)
|
||||
assert "lacks permission for dataset" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
datasets = client.list_datasets()
|
||||
assert len(datasets) == 3, str(datasets)
|
||||
@ -149,9 +150,9 @@ class TestDatasetsDelete:
|
||||
def test_ids_duplicate(self, client, add_datasets_func):
|
||||
dataset_ids = [dataset.id for dataset in add_datasets_func]
|
||||
payload = {"ids": dataset_ids + dataset_ids}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.delete_datasets(**payload)
|
||||
assert "Duplicate ids:" in str(excinfo.value), str(excinfo.value)
|
||||
assert "Duplicate ids:" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
datasets = client.list_datasets()
|
||||
assert len(datasets) == 3, str(datasets)
|
||||
@ -162,17 +163,17 @@ class TestDatasetsDelete:
|
||||
payload = {"ids": dataset_ids}
|
||||
client.delete_datasets(**payload)
|
||||
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.delete_datasets(**payload)
|
||||
assert "lacks permission for dataset" in str(excinfo.value), str(excinfo.value)
|
||||
assert "lacks permission for dataset" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
@pytest.mark.usefixtures("add_dataset_func")
|
||||
def test_field_unsupported(self, client):
|
||||
payload = {"unknown_field": "unknown_field"}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.delete_datasets(**payload)
|
||||
assert "got an unexpected keyword argument 'unknown_field'" in str(excinfo.value), str(excinfo.value)
|
||||
assert "got an unexpected keyword argument 'unknown_field'" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
datasets = client.list_datasets()
|
||||
assert len(datasets) == 1, str(datasets)
|
||||
|
||||
@ -32,9 +32,9 @@ class TestAuthorization:
|
||||
)
|
||||
def test_auth_invalid(self, invalid_auth, expected_message):
|
||||
client = RAGFlow(invalid_auth, HOST_ADDRESS)
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.list_datasets()
|
||||
assert expected_message in str(excinfo.value)
|
||||
assert expected_message in str(exception_info.value)
|
||||
|
||||
|
||||
class TestCapability:
|
||||
@ -46,7 +46,7 @@ class TestCapability:
|
||||
executor.submit(
|
||||
client.list_datasets,
|
||||
)
|
||||
for i in range(count)
|
||||
for _ in range(count)
|
||||
]
|
||||
responses = list(as_completed(futures))
|
||||
assert len(responses) == count, responses
|
||||
@ -89,16 +89,16 @@ class TestDatasetsList:
|
||||
ids=["page_0", "page_a"],
|
||||
)
|
||||
def test_page_invalid(self, client, params, expected_message):
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.list_datasets(**params)
|
||||
assert expected_message in str(excinfo.value), str(excinfo.value)
|
||||
assert expected_message in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
def test_page_none(self, client):
|
||||
params = {"page": None}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.list_datasets(**params)
|
||||
assert "not instance of" in str(excinfo.value), str(excinfo.value)
|
||||
assert "not instance of" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p1
|
||||
@pytest.mark.parametrize(
|
||||
@ -124,16 +124,16 @@ class TestDatasetsList:
|
||||
],
|
||||
)
|
||||
def test_page_size_invalid(self, client, params, expected_message):
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.list_datasets(**params)
|
||||
assert expected_message in str(excinfo.value), str(excinfo.value)
|
||||
assert expected_message in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
def test_page_size_none(self, client):
|
||||
params = {"page_size": None}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.list_datasets(**params)
|
||||
assert "not instance of" in str(excinfo.value), str(excinfo.value)
|
||||
assert "not instance of" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
@pytest.mark.parametrize(
|
||||
@ -160,16 +160,16 @@ class TestDatasetsList:
|
||||
ids=["empty", "unknown", "orderby_create_time_upper", "orderby_update_time_upper", "whitespace"],
|
||||
)
|
||||
def test_orderby_invalid(self, client, params):
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.list_datasets(**params)
|
||||
assert "Input should be 'create_time' or 'update_time'" in str(excinfo.value), str(excinfo.value)
|
||||
assert "Input should be 'create_time' or 'update_time'" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_orderby_none(self, client):
|
||||
params = {"orderby": None}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.list_datasets(**params)
|
||||
assert "not instance of" in str(excinfo.value), str(excinfo.value)
|
||||
assert "not instance of" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
@pytest.mark.parametrize(
|
||||
@ -193,16 +193,16 @@ class TestDatasetsList:
|
||||
ids=["float_value", "invalid_string"],
|
||||
)
|
||||
def test_desc_invalid(self, client, params):
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.list_datasets(**params)
|
||||
assert "not instance of" in str(excinfo.value), str(excinfo.value)
|
||||
assert "not instance of" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_desc_none(self, client):
|
||||
params = {"desc": None}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.list_datasets(**params)
|
||||
assert "not instance of" in str(excinfo.value), str(excinfo.value)
|
||||
assert "not instance of" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p1
|
||||
def test_name(self, client):
|
||||
@ -214,9 +214,9 @@ class TestDatasetsList:
|
||||
@pytest.mark.p2
|
||||
def test_name_wrong(self, client):
|
||||
params = {"name": "wrong name"}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.list_datasets(**params)
|
||||
assert "lacks permission for dataset" in str(excinfo.value), str(excinfo.value)
|
||||
assert "lacks permission for dataset" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
def test_name_empty(self, client):
|
||||
@ -241,30 +241,30 @@ class TestDatasetsList:
|
||||
@pytest.mark.p2
|
||||
def test_id_not_uuid(self, client):
|
||||
params = {"id": "not_uuid"}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.list_datasets(**params)
|
||||
assert "Invalid UUID1 format" in str(excinfo.value), str(excinfo.value)
|
||||
assert "Invalid UUID1 format" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
def test_id_not_uuid1(self, client):
|
||||
params = {"id": uuid.uuid4().hex}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.list_datasets(**params)
|
||||
assert "Invalid UUID1 format" in str(excinfo.value), str(excinfo.value)
|
||||
assert "Invalid UUID1 format" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
def test_id_wrong_uuid(self, client):
|
||||
params = {"id": "d94a8dc02c9711f0930f7fbc369eab6d"}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.list_datasets(**params)
|
||||
assert "lacks permission for dataset" in str(excinfo.value), str(excinfo.value)
|
||||
assert "lacks permission for dataset" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
def test_id_empty(self, client):
|
||||
params = {"id": ""}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.list_datasets(**params)
|
||||
assert "Invalid UUID1 format" in str(excinfo.value), str(excinfo.value)
|
||||
assert "Invalid UUID1 format" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
def test_id_none(self, client):
|
||||
@ -282,6 +282,7 @@ class TestDatasetsList:
|
||||
ids=["name_and_id_match", "name_and_id_mismatch"],
|
||||
)
|
||||
def test_name_and_id(self, client, add_datasets, func, name, expected_num):
|
||||
params = None
|
||||
if callable(func):
|
||||
params = {"id": func(add_datasets), "name": name}
|
||||
datasets = client.list_datasets(**params)
|
||||
@ -301,13 +302,13 @@ class TestDatasetsList:
|
||||
params = {"id": dataset_id(add_datasets), "name": name}
|
||||
else:
|
||||
params = {"id": dataset_id, "name": name}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.list_datasets(**params)
|
||||
assert "lacks permission for dataset" in str(excinfo.value), str(excinfo.value)
|
||||
assert "lacks permission for dataset" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
def test_field_unsupported(self, client):
|
||||
params = {"unknown_field": "unknown_field"}
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.list_datasets(**params)
|
||||
assert "got an unexpected keyword argument" in str(excinfo.value), str(excinfo.value)
|
||||
assert "got an unexpected keyword argument" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@ -30,9 +30,9 @@ class TestRquest:
|
||||
@pytest.mark.p2
|
||||
def test_payload_empty(self, add_dataset_func):
|
||||
dataset = add_dataset_func
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
dataset.update({})
|
||||
assert "No properties were modified" in str(excinfo.value), str(excinfo.value)
|
||||
assert "No properties were modified" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
|
||||
class TestCapability:
|
||||
@ -74,25 +74,25 @@ class TestDatasetUpdate:
|
||||
)
|
||||
def test_name_invalid(self, add_dataset_func, name, expected_message):
|
||||
dataset = add_dataset_func
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
dataset.update({"name": name})
|
||||
assert expected_message in str(excinfo.value), str(excinfo.value)
|
||||
assert expected_message in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_name_duplicated(self, add_datasets_func):
|
||||
datasets = add_datasets_func
|
||||
name = "dataset_1"
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
datasets[0].update({"name": name})
|
||||
assert f"Dataset name '{name}' already exists" in str(excinfo.value), str(excinfo.value)
|
||||
assert f"Dataset name '{name}' already exists" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_name_case_insensitive(self, add_datasets_func):
|
||||
dataset = add_datasets_func[0]
|
||||
name = "DATASET_1"
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
dataset.update({"name": name})
|
||||
assert f"Dataset name '{name}' already exists" in str(excinfo.value), str(excinfo.value)
|
||||
assert f"Dataset name '{name}' already exists" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
def test_avatar(self, client, add_dataset_func, tmp_path):
|
||||
@ -108,9 +108,9 @@ class TestDatasetUpdate:
|
||||
@pytest.mark.p2
|
||||
def test_avatar_exceeds_limit_length(self, add_dataset_func):
|
||||
dataset = add_dataset_func
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
dataset.update({"avatar": "a" * 65536})
|
||||
assert "String should have at most 65535 characters" in str(excinfo.value), str(excinfo.value)
|
||||
assert "String should have at most 65535 characters" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p3
|
||||
@pytest.mark.parametrize(
|
||||
@ -126,9 +126,9 @@ class TestDatasetUpdate:
|
||||
def test_avatar_invalid_prefix(self, add_dataset_func, tmp_path, avatar_prefix, expected_message):
|
||||
dataset = add_dataset_func
|
||||
fn = create_image_file(tmp_path / "ragflow_test.png")
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
dataset.update({"avatar": f"{avatar_prefix}{encode_avatar(fn)}"})
|
||||
assert expected_message in str(excinfo.value), str(excinfo.value)
|
||||
assert expected_message in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_avatar_none(self, client, add_dataset_func):
|
||||
@ -151,9 +151,9 @@ class TestDatasetUpdate:
|
||||
@pytest.mark.p2
|
||||
def test_description_exceeds_limit_length(self, add_dataset_func):
|
||||
dataset = add_dataset_func
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
dataset.update({"description": "a" * 65536})
|
||||
assert "String should have at most 65535 characters" in str(excinfo.value), str(excinfo.value)
|
||||
assert "String should have at most 65535 characters" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_description_none(self, client, add_dataset_func):
|
||||
@ -194,9 +194,9 @@ class TestDatasetUpdate:
|
||||
)
|
||||
def test_embedding_model_invalid(self, add_dataset_func, name, embedding_model):
|
||||
dataset = add_dataset_func
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
dataset.update({"name": name, "embedding_model": embedding_model})
|
||||
error_msg = str(excinfo.value)
|
||||
error_msg = str(exception_info.value)
|
||||
if "tenant_no_auth" in name:
|
||||
assert error_msg == f"Unauthorized model: <{embedding_model}>", error_msg
|
||||
else:
|
||||
@ -218,9 +218,9 @@ class TestDatasetUpdate:
|
||||
)
|
||||
def test_embedding_model_format(self, add_dataset_func, name, embedding_model):
|
||||
dataset = add_dataset_func
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
dataset.update({"name": name, "embedding_model": embedding_model})
|
||||
error_msg = str(excinfo.value)
|
||||
error_msg = str(exception_info.value)
|
||||
if name in ["empty", "space", "missing_at"]:
|
||||
assert "Embedding model identifier must follow <model_name>@<provider> format" in error_msg, error_msg
|
||||
else:
|
||||
@ -267,16 +267,16 @@ class TestDatasetUpdate:
|
||||
)
|
||||
def test_permission_invalid(self, add_dataset_func, permission):
|
||||
dataset = add_dataset_func
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
dataset.update({"permission": permission})
|
||||
assert "Input should be 'me' or 'team'" in str(excinfo.value), str(excinfo.value)
|
||||
assert "Input should be 'me' or 'team'" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_permission_none(self, add_dataset_func):
|
||||
dataset = add_dataset_func
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
dataset.update({"permission": None})
|
||||
assert "Input should be 'me' or 'team'" in str(excinfo.value), str(excinfo.value)
|
||||
assert "Input should be 'me' or 'team'" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p1
|
||||
@pytest.mark.parametrize(
|
||||
@ -317,16 +317,16 @@ class TestDatasetUpdate:
|
||||
)
|
||||
def test_chunk_method_invalid(self, add_dataset_func, chunk_method):
|
||||
dataset = add_dataset_func
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
dataset.update({"chunk_method": chunk_method})
|
||||
assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" in str(excinfo.value), str(excinfo.value)
|
||||
assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_chunk_method_none(self, add_dataset_func):
|
||||
dataset = add_dataset_func
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
dataset.update({"chunk_method": None})
|
||||
assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" in str(excinfo.value), str(excinfo.value)
|
||||
assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.skipif(os.getenv("DOC_ENGINE") == "infinity", reason="#8208")
|
||||
@pytest.mark.p2
|
||||
@ -359,9 +359,9 @@ class TestDatasetUpdate:
|
||||
@pytest.mark.p2
|
||||
def test_pagerank_infinity(self, client, add_dataset_func):
|
||||
dataset = add_dataset_func
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
dataset.update({"pagerank": 50})
|
||||
assert "'pagerank' can only be set when doc_engine is elasticsearch" in str(excinfo.value), str(excinfo.value)
|
||||
assert "'pagerank' can only be set when doc_engine is elasticsearch" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
@pytest.mark.parametrize(
|
||||
@ -374,16 +374,16 @@ class TestDatasetUpdate:
|
||||
)
|
||||
def test_pagerank_invalid(self, add_dataset_func, pagerank, expected_message):
|
||||
dataset = add_dataset_func
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
dataset.update({"pagerank": pagerank})
|
||||
assert expected_message in str(excinfo.value), str(excinfo.value)
|
||||
assert expected_message in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_pagerank_none(self, add_dataset_func):
|
||||
dataset = add_dataset_func
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
dataset.update({"pagerank": None})
|
||||
assert "Input should be a valid integer" in str(excinfo.value), str(excinfo.value)
|
||||
assert "Input should be a valid integer" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p1
|
||||
@pytest.mark.parametrize(
|
||||
@ -625,9 +625,9 @@ class TestDatasetUpdate:
|
||||
)
|
||||
def test_parser_config_invalid(self, add_dataset_func, parser_config, expected_message):
|
||||
dataset = add_dataset_func
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
dataset.update({"parser_config": parser_config})
|
||||
assert expected_message in str(excinfo.value), str(excinfo.value)
|
||||
assert expected_message in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
def test_parser_config_empty(self, client, add_dataset_func):
|
||||
@ -723,9 +723,9 @@ class TestDatasetUpdate:
|
||||
)
|
||||
def test_field_unsupported(self, add_dataset_func, payload):
|
||||
dataset = add_dataset_func
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
dataset.update(payload)
|
||||
assert "Extra inputs are not permitted" in str(excinfo.value), str(excinfo.value)
|
||||
assert "Extra inputs are not permitted" in str(exception_info.value), str(exception_info.value)
|
||||
|
||||
@pytest.mark.p2
|
||||
def test_field_unset(self, client, add_dataset_func):
|
||||
|
||||
Reference in New Issue
Block a user