Пример #1
0
    def test_delete_task_collection_no_status(self, mock_task_status):
        """
        Test get task_collection with no state.
        """

        mock_request = mock.MagicMock()
        mock_request.GET.getlist.return_value = []

        task_collection = TaskCollectionView()
        with self.assertRaises(pulp_exceptions.PulpCodedForbiddenException):
            task_collection.delete(mock_request)
Пример #2
0
    def test_delete_task_collection_no_status(self, mock_task_status):
        """
        Test get task_collection with no state.
        """

        mock_request = mock.MagicMock()
        mock_request.GET.getlist.return_value = []

        task_collection = TaskCollectionView()
        with self.assertRaises(pulp_exceptions.PulpCodedForbiddenException):
            task_collection.delete(mock_request)
Пример #3
0
    def test_delete_task_collection(self, mock_task_status):
        """
        Test get task_collection with tags.
        """

        mock_request = mock.MagicMock()
        mock_request.GET.getlist.return_value = ['finished']

        task_collection = TaskCollectionView()
        task_collection.delete(mock_request)

        mock_task_status.objects.assert_called_once_with(state='finished')
Пример #4
0
    def test_delete_task_collection(self, mock_task_status):
        """
        Test get task_collection with tags.
        """

        mock_request = mock.MagicMock()
        mock_request.GET.getlist.return_value = ['finished']

        task_collection = TaskCollectionView()
        task_collection.delete(mock_request)

        mock_task_status.objects.assert_called_once_with(state='finished')
Пример #5
0
    def test_get_task_collection_no_tags(self, mock_resp, mock_task_status, mock_task_serializer):
        """
        Test get task_collection with no tags.
        """

        mock_request = mock.MagicMock()
        mock_request.GET.getlist.return_value = []
        mock_task_status.objects.return_value = ['mock_1', 'mock_2']
        mock_task_serializer.side_effect = lambda x: x

        task_collection = TaskCollectionView()
        response = task_collection.get(mock_request)

        mock_task_status.objects.assert_called_once_with()
        mock_resp.assert_called_once_with(['mock_1', 'mock_2'])
        mock_task_serializer.assert_has_calls([mock.call('mock_1'), mock.call('mock_2')])
        self.assertTrue(response is mock_resp.return_value)
Пример #6
0
    def test_get_task_collection_no_tags(self, mock_resp, mock_task_status,
                                         mock_task_serializer):
        """
        Test get task_collection with no tags.
        """

        mock_request = mock.MagicMock()
        mock_request.GET.getlist.return_value = []
        mock_task_status.objects.return_value = ['mock_1', 'mock_2']
        mock_task_serializer.side_effect = lambda x: x

        task_collection = TaskCollectionView()
        response = task_collection.get(mock_request)

        mock_task_status.objects.assert_called_once_with()
        mock_resp.assert_called_once_with(['mock_1', 'mock_2'])
        mock_task_serializer.assert_has_calls(
            [mock.call('mock_1'), mock.call('mock_2')])
        self.assertTrue(response is mock_resp.return_value)