11
11
specific language governing permissions and limitations under the License.
12
12
"""
13
13
14
- from mock import MagicMock , patch
15
-
16
14
from django .test import TestCase
15
+ from mock import MagicMock , patch
17
16
18
17
from pipeline_plugins .components .collections .sites .open .cc .base import cc_get_host_id_by_innerip
19
18
@@ -33,7 +32,11 @@ def test__get_business_host_return_empty(self):
33
32
data = cc_get_host_id_by_innerip (self .executor , self .bk_biz_id , self .ip_list , self .supplier_account )
34
33
35
34
mock_cmdb .get_business_host .assert_called_once_with (
36
- self .executor , self .bk_biz_id , self .supplier_account , ["bk_host_id" , "bk_host_innerip" ], self .ip_list
35
+ self .executor ,
36
+ self .bk_biz_id ,
37
+ self .supplier_account ,
38
+ ["bk_host_id" , "bk_host_innerip" , "bk_cloud_id" ],
39
+ self .ip_list ,
37
40
)
38
41
self .assertFalse (data ["result" ])
39
42
self .assertEqual (
@@ -55,7 +58,11 @@ def test__return_host_list_gt_ip_list(self):
55
58
data = cc_get_host_id_by_innerip (self .executor , self .bk_biz_id , self .ip_list , self .supplier_account )
56
59
57
60
mock_cmdb .get_business_host .assert_called_once_with (
58
- self .executor , self .bk_biz_id , self .supplier_account , ["bk_host_id" , "bk_host_innerip" ], self .ip_list
61
+ self .executor ,
62
+ self .bk_biz_id ,
63
+ self .supplier_account ,
64
+ ["bk_host_id" , "bk_host_innerip" , "bk_cloud_id" ],
65
+ self .ip_list ,
59
66
)
60
67
self .assertFalse (data ["result" ])
61
68
self .assertEqual (data ["message" ], "IP [1.1.1.1, 2.2.2.2] 在本业务下重复: 请检查配置, 修复后重新执行 | cc_get_host_id_by_innerip" )
@@ -69,7 +76,11 @@ def test__return_host_list_lt_ip_list(self):
69
76
data = cc_get_host_id_by_innerip (self .executor , self .bk_biz_id , self .ip_list , self .supplier_account )
70
77
71
78
mock_cmdb .get_business_host .assert_called_once_with (
72
- self .executor , self .bk_biz_id , self .supplier_account , ["bk_host_id" , "bk_host_innerip" ], self .ip_list
79
+ self .executor ,
80
+ self .bk_biz_id ,
81
+ self .supplier_account ,
82
+ ["bk_host_id" , "bk_host_innerip" , "bk_cloud_id" ],
83
+ self .ip_list ,
73
84
)
74
85
self .assertFalse (data ["result" ])
75
86
self .assertEqual (data ["message" ], "IP [3.3.3.3] 在本业务下不存在: 请检查配置, 修复后重新执行 | cc_get_host_id_by_innerip" )
@@ -87,7 +98,11 @@ def test__normal(self):
87
98
data = cc_get_host_id_by_innerip (self .executor , self .bk_biz_id , self .ip_list , self .supplier_account )
88
99
89
100
mock_cmdb .get_business_host .assert_called_once_with (
90
- self .executor , self .bk_biz_id , self .supplier_account , ["bk_host_id" , "bk_host_innerip" ], self .ip_list
101
+ self .executor ,
102
+ self .bk_biz_id ,
103
+ self .supplier_account ,
104
+ ["bk_host_id" , "bk_host_innerip" , "bk_cloud_id" ],
105
+ self .ip_list ,
91
106
)
92
107
self .assertTrue (data ["result" ])
93
108
self .assertEqual (data ["data" ], ["1" , "2" , "3" ])
0 commit comments