From eb380cdda9d8e03eb707faf72c3f8e4dcbc37dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E7=A7=8B=E5=B9=B3?= <446105468@qq.com> Date: Thu, 23 Nov 2023 17:14:42 +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 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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 12659d1c0..b93c2e3ef 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 @@ -14,6 +14,7 @@ Proxy2StepAdapterTestCase, ) from apps.core.tag.models import Tag +from apps.node_man.constants import GSE_PACKAGE_ENABLE_ALIAS_MAP from apps.node_man.handlers.meta import MetaHandler from apps.node_man.models import GsePackageDesc, GsePackages from apps.node_man.tests.utils import create_gse_package @@ -84,7 +85,7 @@ def test_list_with_filter_condition(self, *args, **kwargs): # 筛选created_by result = self.client.get(path="/api/agent/package/", data={"created_by": gse_package.created_by}) self.assertEqual(len(result["data"]["list"]), 1) - self.assertEqual(result["data"]["list"][0]["created_by"], "admin") + self.assertEqual(result["data"]["list"][0]["created_by"], gse_package.created_by) result = self.client.get(path="/api/agent/package/", data={"created_by": "system"}) self.assertEqual(len(result["data"]["list"]), 0) @@ -174,13 +175,16 @@ def test_quick_search_condition(self, *args, **kwargs): @patch("apps.node_man.permissions.package_manage.PackageManagePermission.has_permission", return_value=True) def test_filter_condition_with_agent_pkg_manage(self, *args, **kwargs): result = MetaHandler().filter_condition("agent_pkg_manage") + self.assertEqual(len(GsePackages.objects.all()), 1) + gse_package = GsePackages.objects.first() + is_ready = gse_package.is_ready print(f"result3={result}") for condition in result: if condition["id"] == "version": self.assertCountEqual( condition["children"], [ - {"id": "1.0.1", "name": "1.0.1"}, + {"id": gse_package.version, "name": gse_package.version}, ], ) elif condition["id"] == "tags": @@ -195,13 +199,13 @@ def test_filter_condition_with_agent_pkg_manage(self, *args, **kwargs): self.assertCountEqual( condition["children"], [ - {"id": "admin", "name": "admin"}, + {"id": gse_package.created_by, "name": gse_package.created_by}, ], ) elif condition["id"] == "is_ready": self.assertCountEqual( condition["children"], [ - {"id": True, "name": "启用"}, + {"id": is_ready, "name": GSE_PACKAGE_ENABLE_ALIAS_MAP.get(is_ready, is_ready)}, ], )