77import unittest
88
99sys .path .extend (["../" , "./" ])
10- from common import APITestCase # noqa
11- from runner_service .utils import fread # noqa
10+ from common import APITestCase , fake_ssh_client # noqa
11+ from runner_service .utils import fread # noqa
1212
1313# turn of normal logging that the ansible_runner_service will generate
1414nh = logging .NullHandler ()
@@ -102,6 +102,7 @@ def test_host_add(self):
102102 payload = json .loads (response .data )
103103 self .assertTrue (payload ['msg' ].upper ().startswith ('SKIPPED' ))
104104
105+ @fake_ssh_client
105106 def test_host_add_localhost (self ):
106107 """- Add a localhost to a group"""
107108
@@ -124,6 +125,7 @@ def test_host_add_nogroup(self):
124125 self .assertEqual (response .status_code ,
125126 400 )
126127
128+ @fake_ssh_client
127129 def test_host_add_duplicate (self ):
128130 """- Attempt to add a host multiple times to a group"""
129131 dupe_count = 2
@@ -154,6 +156,7 @@ def test_hosts(self):
154156 payload = json .loads (response .data )
155157 self .assertTrue (isinstance (payload ['data' ]['hosts' ], list ))
156158
159+ @fake_ssh_client
157160 def test_remove_valid_host (self ):
158161 """- remove a host from a group"""
159162 response = self .app .post ('api/v1/groups/temphost' )
@@ -177,7 +180,7 @@ def test_remove_invalid_host(self):
177180 response = self .app .delete ('/api/v1/hosts/notthere/groups/invalidhost' )
178181 self .assertEqual (response .status_code ,
179182 400 )
180-
183+ @ fake_ssh_client
181184 def test_check_membership (self ):
182185 """- show groups host is a member of"""
183186 response = self .app .post ('api/v1/groups/groupone' )
@@ -192,6 +195,7 @@ def test_check_membership(self):
192195 payload = json .loads (response .data )
193196 self .assertIn ("groupone" , payload ['data' ]['groups' ])
194197
198+ @fake_ssh_client
195199 def test_show_group_members (self ):
196200 """- show hosts that are members of a specific group"""
197201 response = self .app .post ('api/v1/groups/grouptwo' )
@@ -215,6 +219,7 @@ def test_show_group_members_missing(self):
215219 self .assertEqual (response .status_code ,
216220 404 )
217221
222+ @fake_ssh_client
218223 def test_add_host_multiple_groups (self ):
219224 """- add a host to multiple groups"""
220225
@@ -234,6 +239,7 @@ def test_add_host_multiple_groups(self):
234239 self .assertEqual (response .status_code ,
235240 200 )
236241
242+ @fake_ssh_client
237243 def test_hosts_with_invalid_parms (self ):
238244 """- issue a host/group request with an invalid parameter"""
239245 response = self .app .post ('api/v1/groups/parmcheck' ) # noqa
@@ -243,6 +249,7 @@ def test_hosts_with_invalid_parms(self):
243249 self .assertEqual (response .status_code ,
244250 400 )
245251
252+ @fake_ssh_client
246253 def test_remove_host (self ):
247254 """- remove a host from all groups"""
248255 response = self .app .post ('api/v1/groups/removehost1' )
0 commit comments