From 56acb340d236ac36ba13735c88ec372dc1df86f2 Mon Sep 17 00:00:00 2001 From: liu an Date: Thu, 13 Mar 2025 10:53:07 +0800 Subject: [PATCH] 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 --- .../test_list_dataset.py | 1 - .../test_update_dataset.py | 67 +++++-------------- 2 files changed, 17 insertions(+), 51 deletions(-) diff --git a/sdk/python/test/test_http_api/test_dataset_mangement/test_list_dataset.py b/sdk/python/test/test_http_api/test_dataset_mangement/test_list_dataset.py index 8f167d334..1ace4c3d4 100644 --- a/sdk/python/test/test_http_api/test_dataset_mangement/test_list_dataset.py +++ b/sdk/python/test/test_http_api/test_dataset_mangement/test_list_dataset.py @@ -224,7 +224,6 @@ class TestDatasetList: ): create_datasets(get_http_api_auth, 3) res = list_dataset(get_http_api_auth, params=params) - # print(res) assert res["code"] == expected_code if expected_code == 0: if callable(assertions): diff --git a/sdk/python/test/test_http_api/test_dataset_mangement/test_update_dataset.py b/sdk/python/test/test_http_api/test_dataset_mangement/test_update_dataset.py index e3072c83a..77cab9650 100644 --- a/sdk/python/test/test_http_api/test_dataset_mangement/test_update_dataset.py +++ b/sdk/python/test/test_http_api/test_dataset_mangement/test_update_dataset.py @@ -135,12 +135,7 @@ class TestDatasetUpdate: ("knowledge_graph", 0, ""), ("email", 0, ""), ("tag", 0, ""), - pytest.param( - "", - 0, - "", - marks=pytest.mark.xfail(reason="issue#5920"), - ), + ("", 0, ""), ( "other_chunk_method", 102, @@ -148,12 +143,6 @@ class TestDatasetUpdate: " 'paper', 'book', 'laws', 'presentation', 'picture', 'one', " "'knowledge_graph', 'email', 'tag']", ), - pytest.param( - None, - 0, - "", - marks=pytest.mark.xfail(reason="issue#5920"), - ), ], ) def test_chunk_method( @@ -210,7 +199,7 @@ class TestDatasetUpdate: [ ("me", 0), ("team", 0), - pytest.param("", 0, marks=pytest.mark.xfail(reason="issue#5920")), + ("", 0), ("ME", 102), ("TEAM", 102), ("other_permission", 102), @@ -249,58 +238,31 @@ class TestDatasetUpdate: "payload, expected_code, expected_message", [ ({"chunk_count": 1}, 102, "Can't change `chunk_count`."), - pytest.param( + ( {"create_date": "Tue, 11 Mar 2025 13:37:23 GMT"}, 102, - "", - 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"), + "The input parameters are invalid.", ), + ({"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`."), ({"id": "id"}, 102, "The input parameters are invalid."), - pytest.param( - {"status": "1"}, 102, "", marks=pytest.mark.xfail(reason="issue#5923") - ), + ({"status": "1"}, 102, "The input parameters are invalid."), ( {"tenant_id": "e57c1966f99211efb41e9e45646e0111"}, 102, "Can't change `tenant_id`.", ), - pytest.param( - {"token_num": 1}, 102, "", marks=pytest.mark.xfail(reason="issue#5923") - ), - pytest.param( + ({"token_num": 1}, 102, "The input parameters are invalid."), + ( {"update_date": "Tue, 11 Mar 2025 13:37:23 GMT"}, 102, - "", - 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"), + "The input parameters are invalid.", ), + ({"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 ): ids = create_datasets(get_http_api_auth, 1) @@ -308,6 +270,11 @@ class TestDatasetUpdate: assert res["code"] == expected_code 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): ids = create_datasets(get_http_api_auth, 1)