Пример #1
0
    def test_post_bad_request_content_source(self):
        """
        Test content source invalid action
        """
        request = mock.MagicMock()
        request.body = None
        content_source_view = ContentSourceCollectionActionView()
        response = content_source_view.post(request, 'no-such-action')

        self.assertTrue(isinstance(response, HttpResponseBadRequest))
        self.assertEqual(response.status_code, 400)
Пример #2
0
    def test_refresh_content_source(self, mock_refresh, mock_sources, mock_tags):
        """
        Test refresh content sources
        """
        source = mock.MagicMock()
        source.id = 'some-source'
        source.dict.return_value = {'source_id': 'some-source'}
        mock_sources.return_value = {'some-source': source}

        mock_task_tags = [mock_tags.action_tag.return_value, mock_tags.resource_tag.return_value]

        request = mock.MagicMock()
        request.body = None
        content_source_view = ContentSourceCollectionActionView()
        try:
            content_source_view.post(request, 'refresh')
        except OperationPostponed, response:
            pass