def test_create_instance_check_mode(self): mock_module = mock.MagicMock( params=copy.deepcopy(self.mockModule.params), check_mode=True, ) self.assertEqual((True, -1, 'created(check mode)'), nifcloud.create_instance(mock_module))
def test_create_instance_success(self): with mock.patch('requests.post', self.mockRequestsPostRunInstance): with mock.patch('nifcloud.get_instance_state', self.mockGetInstanceState16): self.assertEqual( (True, 16, 'created'), nifcloud.create_instance(self.mockModule) )
def test_create_instance_without_startup_script_success(self): params = copy.deepcopy(self.mockModule.params) params['startup_script'] = None params['startup_script_vars'] = {} mock_module = mock.MagicMock( params=params, fail_json=copy.deepcopy(self.mockModule.fail_json), check_mode=False, ) with mock.patch('requests.post', self.mockRequestsPostRunInstance): with mock.patch('nifcloud.get_instance_state', self.mockGetInstanceState16): self.assertEqual((True, 16, 'created'), nifcloud.create_instance(mock_module))