Skip to content

Commit

Permalink
feature: 提供 Agent 包管理后台接口 (closed TencentBlueKing#1683)
Browse files Browse the repository at this point in the history
  • Loading branch information
ping15 committed Nov 23, 2023
1 parent 8f071d1 commit eb380cd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions apps/node_man/tests/test_views/test_package_manage_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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":
Expand All @@ -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)},
],
)

0 comments on commit eb380cd

Please sign in to comment.