From 46f9a87667b2fa207a42f3f263c2b403ba2b95a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E7=A7=8B=E5=B9=B3?= <446105468@qq.com> Date: Mon, 20 Nov 2023 16:12:57 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=20=E6=8F=90=E4=BE=9B=20Agent=20?= =?UTF-8?q?=E5=8C=85=E7=AE=A1=E7=90=86=E5=90=8E=E5=8F=B0=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=20(closed=20#1683)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/test_views/test_package_manage_views.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/node_man/tests/test_views/test_package_manage_views.py b/apps/node_man/tests/test_views/test_package_manage_views.py index a7175e4b7..d17d3638d 100644 --- a/apps/node_man/tests/test_views/test_package_manage_views.py +++ b/apps/node_man/tests/test_views/test_package_manage_views.py @@ -8,6 +8,8 @@ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ +from unittest.mock import patch + from apps.backend.tests.subscription.agent_adapter.test_adapter import ( Proxy2StepAdapterTestCase, ) @@ -29,6 +31,7 @@ def clear_agent_data(cls): GsePackageDesc.objects.all().delete() Tag.objects.all().delete() + @patch("apps.node_man.handlers.cmdb.get_request_username", return_value="admin") def test_list(self): # 和之前的builder.make加起来100 create_gse_package(99, start_id=1000) @@ -43,6 +46,7 @@ def test_list(self): self.assertEqual(result["data"]["total"], 100) self.assertEqual(len(result["data"]["list"]), 2) + @patch("apps.node_man.handlers.cmdb.get_request_username", return_value="admin") def test_list_with_filter_condition(self): # 不筛选 result = self.client.get(path="/api/agent/package/") @@ -118,18 +122,21 @@ def collect_all_tag_names(cls, tags): return tag_name_set + @patch("apps.node_man.handlers.cmdb.get_request_username", return_value="admin") def test_update(self): first_gse_package = GsePackages.objects.first() self.assertEqual(first_gse_package.is_ready, True) self.client.put(path=f"/api/agent/package/{first_gse_package.id}/", data={"is_ready": False}) self.assertEqual(GsePackages.objects.first().is_ready, False) + @patch("apps.node_man.handlers.cmdb.get_request_username", return_value="admin") def test_destroy(self): gse_packages = GsePackages.objects.all() self.assertEqual(len(gse_packages), 1) self.client.delete(path=f"/api/agent/package/{gse_packages.first().id}/") self.assertEqual(len(GsePackages.objects.all()), 0) + @patch("apps.node_man.handlers.cmdb.get_request_username", return_value="admin") def test_quick_search_condition(self): result = self.client.get(path="/api/agent/package/quick_search_condition/") print(f"result2={result}") @@ -151,6 +158,7 @@ def test_quick_search_condition(self): ], ) + @patch("apps.node_man.handlers.cmdb.get_request_username", return_value="admin") def test_filter_condition_with_agent_pkg_manage(self): result = MetaHandler().filter_condition("agent_pkg_manage") print(f"result3={result}")