From d3cc1ad8e30ec3b39c24ace272bab00dac58a341 Mon Sep 17 00:00:00 2001 From: dcd <1151627903@qq.com> Date: Thu, 5 Dec 2024 20:45:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=B7=AE=E9=87=8F?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=B8=BB=E6=9C=BA=E5=BF=BD=E7=95=A5=E5=86=85?= =?UTF-8?q?=E7=BD=91IP=E5=8F=98=E6=9B=B4=E5=9C=BA=E6=99=AF=20(closed=20#25?= =?UTF-8?q?04)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/mock_data/views_mkd/job.py | 2 +- apps/node_man/tests/test_views/test_job_views.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/mock_data/views_mkd/job.py b/apps/mock_data/views_mkd/job.py index 1bf6b9806..8ee62b7dd 100644 --- a/apps/mock_data/views_mkd/job.py +++ b/apps/mock_data/views_mkd/job.py @@ -39,7 +39,7 @@ ], "retention": 1, } -# 因为MockClient中接口数据定义死了,如需调用使用深拷贝后update原数据 +# 因为MockClient中接口数据定义死了,如需调用使用,深拷贝后update原数据 JOB_REINSTALL_REQUEST_PARAMS = { "job_type": constants.JobType.REINSTALL_AGENT, "hosts": [ diff --git a/apps/node_man/tests/test_views/test_job_views.py b/apps/node_man/tests/test_views/test_job_views.py index 62783f3c8..0aa90bfaa 100644 --- a/apps/node_man/tests/test_views/test_job_views.py +++ b/apps/node_man/tests/test_views/test_job_views.py @@ -17,7 +17,7 @@ from apps.mock_data.common_unit import host from apps.mock_data.views_mkd import job from apps.node_man import constants -from apps.node_man.models import Host +from apps.node_man.models import Host, IdentityData from apps.node_man.tests.utils import MockClient, Subscription from apps.utils.unittest.testcase import CustomAPITestCase, MockSuperUserMixin @@ -107,13 +107,18 @@ def setUp(self) -> None: }, bk_host_id=14110, ) + identify_data = copy.deepcopy(host.IDENTITY_MODEL_DATA) + identify_data["bk_host_id"] = 14110 + IdentityData.objects.create(**identify_data) return super().setUp() - @patch("apps.node_man.periodic_tasks.sync_cmdb_host.client_v2", MockClient) @patch("apps.node_man.handlers.job.JobHandler.create_subscription", Subscription.create_subscription) + @patch("apps.node_man.periodic_tasks.sync_cmdb_host.client_v2", MockClient) def test_install(self): data = copy.deepcopy(job.JOB_REINSTALL_REQUEST_PARAMS) data["hosts"][0]["inner_ip"] = "2.1.2.52" + response = self.client.post(path="/api/job/install/", data=data) # 成功创建安装任务 self.assertEqual(response["result"], True) + self.assertEqual(type(response["data"]["job_id"]), int)