コード例 #1
0
    def test_delete_queued_images_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_all_queued_images(mock_options, None),
            cache_manage.SUCCESS)
        self.assertFalse(mock_client.called)
コード例 #2
0
    def test_delete_queued_images_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_all_queued_images(mock_options, None))
        self.assertFalse(mock_client.called)
コード例 #3
0
    def test_delete_queued_images_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_all_queued_images(mock_options, None),
            cache_manage.SUCCESS)
        self.assertTrue(mock_client.called)
        self.assertIn(mock.call.mock_client().delete_all_queued_images(),
                      manager.mock_calls)
コード例 #4
0
    def test_delete_queued_images_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_all_queued_images(mock_options, None))
        self.assertTrue(mock_client.called)
        self.assertIn(
            mock.call.mock_client().delete_all_queued_images(),
            manager.mock_calls)