mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-13 08:28:22 +08:00
Revert "Refactor: dataset / kb API to RESTFul style" (#13646)
Reverts infiniflow/ragflow#13619
This commit is contained in:
@@ -23,7 +23,7 @@ from utils import encode_avatar
|
||||
from utils.file_utils import create_image_file
|
||||
from utils.hypothesis_utils import valid_names
|
||||
|
||||
from test_http_api.common import create_dataset
|
||||
from common import create_dataset
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("clear_datasets")
|
||||
@@ -32,11 +32,11 @@ class TestAuthorization:
|
||||
@pytest.mark.parametrize(
|
||||
"invalid_auth, expected_code, expected_message",
|
||||
[
|
||||
(None, 401, "<Unauthorized '401: Unauthorized'>"),
|
||||
(None, 0, "`Authorization` can't be empty"),
|
||||
(
|
||||
RAGFlowHttpApiAuth(INVALID_API_TOKEN),
|
||||
401,
|
||||
"<Unauthorized '401: Unauthorized'>",
|
||||
109,
|
||||
"Authentication error: API key is invalid!",
|
||||
),
|
||||
],
|
||||
ids=["empty_auth", "invalid_api_token"],
|
||||
@@ -250,7 +250,7 @@ class TestDatasetCreate:
|
||||
def test_embedding_model_invalid(self, HttpApiAuth, name, embedding_model):
|
||||
payload = {"name": name, "embedding_model": embedding_model}
|
||||
res = create_dataset(HttpApiAuth, payload)
|
||||
assert res["code"] == 102, res
|
||||
assert res["code"] == 101, res
|
||||
if "tenant_no_auth" in name:
|
||||
assert res["message"] == f"Unauthorized model: <{embedding_model}>", res
|
||||
else:
|
||||
|
||||
@@ -31,11 +31,11 @@ class TestAuthorization:
|
||||
@pytest.mark.parametrize(
|
||||
"invalid_auth, expected_code, expected_message",
|
||||
[
|
||||
(None, 401, "<Unauthorized '401: Unauthorized'>"),
|
||||
(None, 0, "`Authorization` can't be empty"),
|
||||
(
|
||||
RAGFlowHttpApiAuth(INVALID_API_TOKEN),
|
||||
401,
|
||||
"<Unauthorized '401: Unauthorized'>",
|
||||
109,
|
||||
"Authentication error: API key is invalid!",
|
||||
),
|
||||
],
|
||||
)
|
||||
@@ -160,7 +160,7 @@ class TestDatasetsDelete:
|
||||
def test_id_wrong_uuid(self, HttpApiAuth):
|
||||
payload = {"ids": ["d94a8dc02c9711f0930f7fbc369eab6d"]}
|
||||
res = delete_datasets(HttpApiAuth, payload)
|
||||
assert res["code"] == 102, res
|
||||
assert res["code"] == 108, res
|
||||
assert "lacks permission for dataset" in res["message"], res
|
||||
|
||||
res = list_datasets(HttpApiAuth)
|
||||
@@ -180,7 +180,7 @@ class TestDatasetsDelete:
|
||||
if callable(func):
|
||||
payload = func(dataset_ids)
|
||||
res = delete_datasets(HttpApiAuth, payload)
|
||||
assert res["code"] == 102, res
|
||||
assert res["code"] == 108, res
|
||||
assert "lacks permission for dataset" in res["message"], res
|
||||
|
||||
res = list_datasets(HttpApiAuth)
|
||||
@@ -205,7 +205,7 @@ class TestDatasetsDelete:
|
||||
assert res["code"] == 0, res
|
||||
|
||||
res = delete_datasets(HttpApiAuth, payload)
|
||||
assert res["code"] == 102, res
|
||||
assert res["code"] == 108, res
|
||||
assert "lacks permission for dataset" in res["message"], res
|
||||
|
||||
@pytest.mark.p3
|
||||
|
||||
@@ -24,8 +24,8 @@ class TestAuthorization:
|
||||
@pytest.mark.parametrize(
|
||||
"invalid_auth, expected_code, expected_message",
|
||||
[
|
||||
(None, 401, "<Unauthorized '401: Unauthorized'>"),
|
||||
(RAGFlowHttpApiAuth(INVALID_API_TOKEN), 401, "<Unauthorized '401: Unauthorized'>"),
|
||||
(None, 0, "Authorization"),
|
||||
(RAGFlowHttpApiAuth(INVALID_API_TOKEN), 109, "API key is invalid"),
|
||||
],
|
||||
)
|
||||
def test_invalid_auth(self, invalid_auth, expected_code, expected_message):
|
||||
|
||||
@@ -28,11 +28,11 @@ class TestAuthorization:
|
||||
@pytest.mark.parametrize(
|
||||
"invalid_auth, expected_code, expected_message",
|
||||
[
|
||||
(None, 401, "<Unauthorized '401: Unauthorized'>"),
|
||||
(None, 0, "`Authorization` can't be empty"),
|
||||
(
|
||||
RAGFlowHttpApiAuth(INVALID_API_TOKEN),
|
||||
401,
|
||||
"<Unauthorized '401: Unauthorized'>",
|
||||
109,
|
||||
"Authentication error: API key is invalid!",
|
||||
),
|
||||
],
|
||||
)
|
||||
@@ -237,7 +237,7 @@ class TestDatasetsList:
|
||||
def test_name_wrong(self, HttpApiAuth):
|
||||
params = {"name": "wrong name"}
|
||||
res = list_datasets(HttpApiAuth, params)
|
||||
assert res["code"] == 102, res
|
||||
assert res["code"] == 108, res
|
||||
assert "lacks permission for dataset" in res["message"], res
|
||||
|
||||
@pytest.mark.p2
|
||||
@@ -281,7 +281,7 @@ class TestDatasetsList:
|
||||
def test_id_wrong_uuid(self, HttpApiAuth):
|
||||
params = {"id": "d94a8dc02c9711f0930f7fbc369eab6d"}
|
||||
res = list_datasets(HttpApiAuth, params)
|
||||
assert res["code"] == 102, res
|
||||
assert res["code"] == 108, res
|
||||
assert "lacks permission for dataset" in res["message"], res
|
||||
|
||||
@pytest.mark.p2
|
||||
|
||||
@@ -33,11 +33,11 @@ class TestAuthorization:
|
||||
@pytest.mark.parametrize(
|
||||
"invalid_auth, expected_code, expected_message",
|
||||
[
|
||||
(None, 401, "<Unauthorized '401: Unauthorized'>"),
|
||||
(None, 0, "`Authorization` can't be empty"),
|
||||
(
|
||||
RAGFlowHttpApiAuth(INVALID_API_TOKEN),
|
||||
401,
|
||||
"<Unauthorized '401: Unauthorized'>",
|
||||
109,
|
||||
"Authentication error: API key is invalid!",
|
||||
),
|
||||
],
|
||||
ids=["empty_auth", "invalid_api_token"],
|
||||
@@ -76,7 +76,7 @@ class TestRquest:
|
||||
def test_payload_empty(self, HttpApiAuth, add_dataset_func):
|
||||
dataset_id = add_dataset_func
|
||||
res = update_dataset(HttpApiAuth, dataset_id, {})
|
||||
assert res["code"] == 102, res
|
||||
assert res["code"] == 101, res
|
||||
assert res["message"] == "No properties were modified", res
|
||||
|
||||
@pytest.mark.p3
|
||||
@@ -313,7 +313,7 @@ class TestDatasetUpdate:
|
||||
dataset_id = add_dataset_func
|
||||
payload = {"name": name, "embedding_model": embedding_model}
|
||||
res = update_dataset(HttpApiAuth, dataset_id, payload)
|
||||
assert res["code"] == 102, res
|
||||
assert res["code"] == 101, res
|
||||
if "tenant_no_auth" in name:
|
||||
assert res["message"] == f"Unauthorized model: <{embedding_model}>", res
|
||||
else:
|
||||
@@ -494,7 +494,7 @@ class TestDatasetUpdate:
|
||||
dataset_id = add_dataset_func
|
||||
payload = {"pagerank": 50}
|
||||
res = update_dataset(HttpApiAuth, dataset_id, payload)
|
||||
assert res["code"] == 102, res
|
||||
assert res["code"] == 101, res
|
||||
assert res["message"] == "'pagerank' can only be set when doc_engine is elasticsearch", res
|
||||
|
||||
@pytest.mark.p2
|
||||
|
||||
Reference in New Issue
Block a user