def test_attach_volume_attached(self): with mock.patch('nifcloud_volume.get_volume_state', mock.MagicMock(return_value=('attached', 'test001'))): self.assertEqual( (False, 'attached'), nifcloud_volume.attach_volume(self.mockModule) )
def test_attach_volume_success(self): with mock.patch('nifcloud_volume.get_volume_state', mock.MagicMock(return_value=('available', 'test001'))): with mock.patch('requests.get', self.mockRequestsGetAttachVolume): self.assertEqual( (True, 'attached'), nifcloud_volume.attach_volume(self.mockModule))
def test_attach_volume_check_mode(self): mockModule = mock.MagicMock( params=copy.deepcopy(self.mockModule.params), check_mode=True, ) with mock.patch('nifcloud_volume.get_volume_state', mock.MagicMock(return_value=('available', 'test001'))): self.assertEqual((True, 'available'), nifcloud_volume.attach_volume(mockModule))