def test_delete_cached_image_not_forced_not_confirmed( self, mock_client, mock_confirm): # options.forced set to False and delete confirmation set to False. mock_confirm.return_value = False mock_options = mock.Mock() mock_options.force = False self.assertEqual( cache_manage.delete_cached_image(mock_options, ['img_id']), cache_manage.SUCCESS) self.assertFalse(mock_client.called)
def test_delete_cached_image_not_forced_not_confirmed(self, mock_client, mock_confirm): # options.forced set to False and delete confirmation set to False. mock_confirm.return_value = False mock_options = mock.Mock() mock_options.force = False self.assertEqual( cache_manage.SUCCESS, cache_manage.delete_cached_image(mock_options, ['img_id'])) self.assertFalse(mock_client.called)
def test_delete_cached_image_not_forced_confirmed(self, mock_client, mock_confirm): # options.forced set to False and delete confirmation set to True. mock_confirm.return_value = True mock_options = mock.Mock() mock_options.force = False mock_options.verbose = True # to cover additional condition and line manager = mock.MagicMock() manager.attach_mock(mock_client, 'mock_client') self.assertEqual( cache_manage.delete_cached_image(mock_options, ['img_id']), cache_manage.SUCCESS) self.assertIn(mock.call.mock_client().delete_cached_image('img_id'), manager.mock_calls)
def test_delete_cached_image_not_forced_confirmed(self, mock_client, mock_confirm): # options.forced set to False and delete confirmation set to True. mock_confirm.return_value = True mock_options = mock.Mock() mock_options.force = False mock_options.verbose = True # to cover additional condition and line manager = mock.MagicMock() manager.attach_mock(mock_client, 'mock_client') self.assertEqual( cache_manage.SUCCESS, cache_manage.delete_cached_image(mock_options, ['img_id'])) self.assertIn( mock.call.mock_client().delete_cached_image('img_id'), manager.mock_calls)
def test_delete_cached_image_without_index(self): self.assertEqual(cache_manage.FAILURE, cache_manage.delete_cached_image(mock.Mock(), []))
def test_delete_cached_image_without_index(self): self.assertEqual(cache_manage.delete_cached_image(mock.Mock(), []), cache_manage.FAILURE)