Ejemplo n.º 1
0
    def test_refresh_invalid_content_source(self, mock_sources):
        """
        Test refresh invalid content source
        """
        mock_sources.return_value = {}

        request = mock.MagicMock()
        request.body = None
        content_source_view = ContentSourceResourceActionView()
        try:
            content_source_view.post(request, 'some-source', 'refresh')
        except MissingResource, response:
            pass
Ejemplo n.º 2
0
    def test_refresh_invalid_content_source(self, mock_sources):
        """
        Test refresh invalid content source
        """
        mock_sources.return_value = {}

        request = mock.MagicMock()
        request.body = None
        content_source_view = ContentSourceResourceActionView()
        try:
            content_source_view.post(request, 'some-source', 'refresh')
        except MissingResource, response:
            pass
Ejemplo n.º 3
0
    def test_post_invalid_action(self, mock_sources):
        """
        Test specific content source invalid action
        """
        source = mock.MagicMock()
        source.id = 'some-source'
        source.dict.return_value = {'source_id': 'some-source'}
        mock_sources.return_value = {'some-source': source}

        request = mock.MagicMock()
        request.body = None
        content_source_view = ContentSourceResourceActionView()
        response = content_source_view.post(request, 'some-source', 'no-such-action')

        self.assertTrue(isinstance(response, HttpResponseBadRequest))
        self.assertEqual(response.status_code, 400)
Ejemplo n.º 4
0
    def test_post_invalid_action(self, mock_sources):
        """
        Test specific content source invalid action
        """
        source = mock.MagicMock()
        source.id = 'some-source'
        source.dict.return_value = {'source_id': 'some-source'}
        mock_sources.return_value = {'some-source': source}

        request = mock.MagicMock()
        request.body = None
        content_source_view = ContentSourceResourceActionView()
        response = content_source_view.post(request, 'some-source', 'no-such-action')

        self.assertTrue(isinstance(response, HttpResponseBadRequest))
        self.assertEqual(response.status_code, 400)
Ejemplo n.º 5
0
    def test_refresh_specific_action(self, mock_refresh, mock_sources, mock_tags):
        """
        Test refresh specific content source
        """
        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 = ContentSourceResourceActionView()
        try:
            content_source_view.post(request, 'some-source', 'refresh')
        except OperationPostponed, response:
            pass
Ejemplo n.º 6
0
    def test_refresh_specific_action(self, mock_refresh, mock_sources, mock_tags):
        """
        Test refresh specific content source
        """
        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 = ContentSourceResourceActionView()
        try:
            content_source_view.post(request, 'some-source', 'refresh')
        except OperationPostponed, response:
            pass
Ejemplo n.º 7
0
     OrphanCollectionView.as_view(),
     name='content_orphan_collection'),
 url(r'^v2/content/orphans/(?P<content_type>[^/]+)/$',
     OrphanTypeSubCollectionView.as_view(),
     name='content_orphan_type_subcollection'),
 url(r'^v2/content/orphans/(?P<content_type>[^/]+)/(?P<unit_id>[^/]+)/$',
     OrphanResourceView.as_view(),
     name='content_orphan_resource'),
 url(r'^v2/content/sources/$',
     ContentSourceCollectionView.as_view(),
     name='content_sources'),
 url(r'^v2/content/sources/action/(?P<action>[^/]+)/$',
     ContentSourceCollectionActionView.as_view(),
     name='content_sources_action'),
 url(r'^v2/content/sources/(?P<source_id>[^/]+)/action/(?P<action>[^/]+)/$',
     ContentSourceResourceActionView.as_view(),
     name='content_sources_resource_action'),
 url(r'^v2/content/sources/(?P<source_id>[^/]+)/$',
     ContentSourceResourceView.as_view(),
     name='content_sources_resource'),
 url(r'^v2/content/units/(?P<type_id>[^/]+)/$',
     ContentUnitsCollectionView.as_view(),
     name='content_units_collection'),
 url(r'^v2/content/units/(?P<type_id>[^/]+)/search/$',
     ContentUnitSearch.as_view(),
     name='content_unit_search'),
 url(r'^v2/content/units/(?P<type_id>[^/]+)/(?P<unit_id>[^/]+)/$',
     ContentUnitResourceView.as_view(),
     name='content_unit_resource'),
 url(r'^v2/content/units/(?P<type_id>[^/]+)/(?P<unit_id>[^/]+)/pulp_user_metadata/$',
     ContentUnitUserMetadataResourceView.as_view(),
Ejemplo n.º 8
0
     name='content_actions_delete_orphans'),
 url(r'^v2/content/catalog/(?P<source_id>[^/]+)/$', CatalogResourceView.as_view(),
     name='content_catalog_resource'),
 url(r'^v2/content/orphans/$', OrphanCollectionView.as_view(), name='content_orphan_collection'),
 url(r'^v2/content/orphans/(?P<content_type>[^/]+)/$', OrphanTypeSubCollectionView.as_view(),
     name='content_orphan_type_subcollection'),
 url(r'^v2/content/orphans/(?P<content_type>[^/]+)/(?P<unit_id>[^/]+)/$',
     OrphanResourceView.as_view(), name='content_orphan_resource'),
 url(r'^v2/content/sources/$',
     ContentSourceCollectionView.as_view(),
     name='content_sources'),
 url(r'^v2/content/sources/action/(?P<action>[^/]+)/$',
     ContentSourceCollectionActionView.as_view(),
     name='content_sources_action'),
 url(r'^v2/content/sources/(?P<source_id>[^/]+)/action/(?P<action>[^/]+)/$',
     ContentSourceResourceActionView.as_view(), name='content_sources_resource_action'),
 url(r'^v2/content/sources/(?P<source_id>[^/]+)/$', ContentSourceResourceView.as_view(),
     name='content_sources_resource'),
 url(r'^v2/content/units/(?P<type_id>[^/]+)/$', ContentUnitsCollectionView.as_view(),
     name='content_units_collection'),
 url(r'^v2/content/units/(?P<type_id>[^/]+)/search/$', ContentUnitSearch.as_view(),
     name='content_unit_search'),
 url(r'^v2/content/units/(?P<type_id>[^/]+)/(?P<unit_id>[^/]+)/$',
     ContentUnitResourceView.as_view(), name='content_unit_resource'),
 url(r'^v2/content/units/(?P<type_id>[^/]+)/(?P<unit_id>[^/]+)/pulp_user_metadata/$',
     ContentUnitUserMetadataResourceView.as_view(), name='content_unit_user_metadata_resource'),
 url(r'^v2/content/uploads/$', UploadsCollectionView.as_view(), name='content_uploads'),
 url(r'^v2/content/uploads/(?P<upload_id>[^/]+)/$', UploadResourceView.as_view(),
     name='content_upload_resource'),
 url(r'^v2/content/uploads/(?P<upload_id>[^/]+)/(?P<offset>[^/]+)/$',
     UploadSegmentResourceView.as_view(), name='content_upload_segment_resource'),
Ejemplo n.º 9
0
     name='content_actions_delete_orphans'),
 url(r'^v2/content/catalog/(?P<source_id>[^/]+)/$', CatalogResourceView.as_view(),
     name='content_catalog_resource'),
 url(r'^v2/content/orphans/$', OrphanCollectionView.as_view(), name='content_orphan_collection'),
 url(r'^v2/content/orphans/(?P<content_type>[^/]+)/$', OrphanTypeSubCollectionView.as_view(),
     name='content_orphan_type_subcollection'),
 url(r'^v2/content/orphans/(?P<content_type>[^/]+)/(?P<unit_id>[^/]+)/$',
     OrphanResourceView.as_view(), name='content_orphan_resource'),
 url(r'^v2/content/sources/$',
     ContentSourceCollectionView.as_view(),
     name='content_sources'),
 url(r'^v2/content/sources/action/(?P<action>[^/]+)/$',
     ContentSourceCollectionActionView.as_view(),
     name='content_sources_action'),
 url(r'^v2/content/sources/(?P<source_id>[^/]+)/action/(?P<action>[^/]+)/$',
     ContentSourceResourceActionView.as_view(), name='content_sources_resource_action'),
 url(r'^v2/content/sources/(?P<source_id>[^/]+)/$', ContentSourceResourceView.as_view(),
     name='content_sources_resource'),
 url(r'^v2/content/units/(?P<type_id>[^/]+)/$', ContentUnitsCollectionView.as_view(),
     name='content_units_collection'),
 url(r'^v2/content/units/(?P<type_id>[^/]+)/search/$', ContentUnitSearch.as_view(),
     name='content_unit_search'),
 url(r'^v2/content/units/(?P<type_id>[^/]+)/(?P<unit_id>[^/]+)/$',
     ContentUnitResourceView.as_view(), name='content_unit_resource'),
 url(r'^v2/content/units/(?P<type_id>[^/]+)/(?P<unit_id>[^/]+)/pulp_user_metadata/$',
     ContentUnitUserMetadataResourceView.as_view(), name='content_unit_user_metadata_resource'),
 url(r'^v2/content/uploads/$', UploadsCollectionView.as_view(), name='content_uploads'),
 url(r'^v2/content/uploads/(?P<upload_id>[^/]+)/$', UploadResourceView.as_view(),
     name='content_upload_resource'),
 url(r'^v2/content/uploads/(?P<upload_id>[^/]+)/(?P<offset>[^/]+)/$',
     UploadSegmentResourceView.as_view(), name='content_upload_segment_resource'),