Пример #1
0
    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)
Пример #2
0
    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)
Пример #3
0
    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)
Пример #4
0
    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)
Пример #5
0
 def test_delete_cached_image_without_index(self):
     self.assertEqual(cache_manage.FAILURE,
                      cache_manage.delete_cached_image(mock.Mock(), []))
Пример #6
0
 def test_delete_cached_image_without_index(self):
     self.assertEqual(cache_manage.delete_cached_image(mock.Mock(), []),
                      cache_manage.FAILURE)