Test: update test cases per issue #5920 #5923 (#6007)

### What problem does this PR solve?

update test cases per issue #5920 #5923

### Type of change

- [x] update test case
This commit is contained in:
liu an 2025-03-13 10:53:07 +08:00 committed by GitHub
parent e05cdc2f9c
commit 56acb340d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 51 deletions

View File

@ -224,7 +224,6 @@ class TestDatasetList:
): ):
create_datasets(get_http_api_auth, 3) create_datasets(get_http_api_auth, 3)
res = list_dataset(get_http_api_auth, params=params) res = list_dataset(get_http_api_auth, params=params)
# print(res)
assert res["code"] == expected_code assert res["code"] == expected_code
if expected_code == 0: if expected_code == 0:
if callable(assertions): if callable(assertions):

View File

@ -135,12 +135,7 @@ class TestDatasetUpdate:
("knowledge_graph", 0, ""), ("knowledge_graph", 0, ""),
("email", 0, ""), ("email", 0, ""),
("tag", 0, ""), ("tag", 0, ""),
pytest.param( ("", 0, ""),
"",
0,
"",
marks=pytest.mark.xfail(reason="issue#5920"),
),
( (
"other_chunk_method", "other_chunk_method",
102, 102,
@ -148,12 +143,6 @@ class TestDatasetUpdate:
" 'paper', 'book', 'laws', 'presentation', 'picture', 'one', " " 'paper', 'book', 'laws', 'presentation', 'picture', 'one', "
"'knowledge_graph', 'email', 'tag']", "'knowledge_graph', 'email', 'tag']",
), ),
pytest.param(
None,
0,
"",
marks=pytest.mark.xfail(reason="issue#5920"),
),
], ],
) )
def test_chunk_method( def test_chunk_method(
@ -210,7 +199,7 @@ class TestDatasetUpdate:
[ [
("me", 0), ("me", 0),
("team", 0), ("team", 0),
pytest.param("", 0, marks=pytest.mark.xfail(reason="issue#5920")), ("", 0),
("ME", 102), ("ME", 102),
("TEAM", 102), ("TEAM", 102),
("other_permission", 102), ("other_permission", 102),
@ -249,58 +238,31 @@ class TestDatasetUpdate:
"payload, expected_code, expected_message", "payload, expected_code, expected_message",
[ [
({"chunk_count": 1}, 102, "Can't change `chunk_count`."), ({"chunk_count": 1}, 102, "Can't change `chunk_count`."),
pytest.param( (
{"create_date": "Tue, 11 Mar 2025 13:37:23 GMT"}, {"create_date": "Tue, 11 Mar 2025 13:37:23 GMT"},
102, 102,
"", "The input parameters are invalid.",
marks=pytest.mark.xfail(reason="issue#5923"),
),
pytest.param(
{"create_time": 1741671443322},
102,
"",
marks=pytest.mark.xfail(reason="issue#5923"),
),
pytest.param(
{"created_by": "aa"},
102,
"",
marks=pytest.mark.xfail(reason="issue#5923"),
), ),
({"create_time": 1741671443322}, 102, "The input parameters are invalid."),
({"created_by": "aa"}, 102, "The input parameters are invalid."),
({"document_count": 1}, 102, "Can't change `document_count`."), ({"document_count": 1}, 102, "Can't change `document_count`."),
({"id": "id"}, 102, "The input parameters are invalid."), ({"id": "id"}, 102, "The input parameters are invalid."),
pytest.param( ({"status": "1"}, 102, "The input parameters are invalid."),
{"status": "1"}, 102, "", marks=pytest.mark.xfail(reason="issue#5923")
),
( (
{"tenant_id": "e57c1966f99211efb41e9e45646e0111"}, {"tenant_id": "e57c1966f99211efb41e9e45646e0111"},
102, 102,
"Can't change `tenant_id`.", "Can't change `tenant_id`.",
), ),
pytest.param( ({"token_num": 1}, 102, "The input parameters are invalid."),
{"token_num": 1}, 102, "", marks=pytest.mark.xfail(reason="issue#5923") (
),
pytest.param(
{"update_date": "Tue, 11 Mar 2025 13:37:23 GMT"}, {"update_date": "Tue, 11 Mar 2025 13:37:23 GMT"},
102, 102,
"", "The input parameters are invalid.",
marks=pytest.mark.xfail(reason="issue#5923"),
),
pytest.param(
{"update_time": 1741671443339},
102,
"",
marks=pytest.mark.xfail(reason="issue#5923"),
),
pytest.param(
{"unknown_field": 0},
100,
"",
marks=pytest.mark.xfail(reason="issue#5923"),
), ),
({"update_time": 1741671443339}, 102, "The input parameters are invalid."),
], ],
) )
def test_modify_unsupported_field( def test_modify_read_only_field(
self, get_http_api_auth, payload, expected_code, expected_message self, get_http_api_auth, payload, expected_code, expected_message
): ):
ids = create_datasets(get_http_api_auth, 1) ids = create_datasets(get_http_api_auth, 1)
@ -308,6 +270,11 @@ class TestDatasetUpdate:
assert res["code"] == expected_code assert res["code"] == expected_code
assert res["message"] == expected_message assert res["message"] == expected_message
def test_modify_unknown_field(self, get_http_api_auth):
ids = create_datasets(get_http_api_auth, 1)
res = update_dataset(get_http_api_auth, ids[0], {"unknown_field": 0})
assert res["code"] == 100
def test_concurrent_update(self, get_http_api_auth): def test_concurrent_update(self, get_http_api_auth):
ids = create_datasets(get_http_api_auth, 1) ids = create_datasets(get_http_api_auth, 1)