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

        request = mock.MagicMock()
        content_source_view = ContentSourceResourceView()
        try:
            content_source_view.get(request, 'some-source')
        except MissingResource, response:
            pass
Ejemplo n.º 2
0
    def test_get_invalid_content_source_resource(self, mock_sources):
        """
        Get invalid content source
        """
        mock_sources.return_value = {}

        request = mock.MagicMock()
        content_source_view = ContentSourceResourceView()
        try:
            content_source_view.get(request, 'some-source')
        except MissingResource, response:
            pass
Ejemplo n.º 3
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 = ContentSourceResourceView()
        try:
            content_source_view.post(request, 'some-source', 'refresh')
        except MissingResource, response:
            pass
Ejemplo n.º 4
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 = ContentSourceResourceView()
        try:
            content_source_view.post(request, 'some-source', 'refresh')
        except MissingResource, response:
            pass
Ejemplo n.º 5
0
    def test_get_content_source_resource(self, mock_sources, mock_resp):
        """
        Get 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}

        request = mock.MagicMock()
        content_source_view = ContentSourceResourceView()
        response = content_source_view.get(request, 'some-source')

        mock_resp.assert_called_once_with(
            {'source_id': 'some-source', '_href': '/v2/content/sources/some-source/'})
        self.assertTrue(response is mock_resp.return_value)
Ejemplo n.º 6
0
    def test_post_bad_request_specific_content_source(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 = ContentSourceResourceView()
        response = content_source_view.post(request, 'some-source', 'no-such-action')

        self.assertTrue(isinstance(response, HttpResponseBadRequest))
        self.assertEqual(response.status_code, 400)
Ejemplo n.º 7
0
    def test_get_content_source_resource(self, mock_sources, mock_resp):
        """
        Get 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}

        request = mock.MagicMock()
        content_source_view = ContentSourceResourceView()
        response = content_source_view.get(request, 'some-source')

        mock_resp.assert_called_once_with(
            {'source_id': 'some-source', '_href': '/v2/content/sources/some-source/'})
        self.assertTrue(response is mock_resp.return_value)
Ejemplo n.º 8
0
    def test_post_bad_request_specific_content_source(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 = ContentSourceResourceView()
        response = content_source_view.post(request, 'some-source',
                                            'no-such-action')

        self.assertTrue(isinstance(response, HttpResponseBadRequest))
        self.assertEqual(response.status_code, 400)
Ejemplo n.º 9
0
    def test_refresh_specific_content_source(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 = ContentSourceResourceView()
        try:
            content_source_view.post(request, 'some-source', 'refresh')
        except OperationPostponed, response:
            pass
Ejemplo n.º 10
0
    def test_refresh_specific_content_source(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 = ContentSourceResourceView()
        try:
            content_source_view.post(request, 'some-source', 'refresh')
        except OperationPostponed, response:
            pass
Ejemplo n.º 11
0
     ConsumerGroupBindingView.as_view(), name='consumer_group_unbind'),
 url(r'^v2/content/actions/delete_orphans/$', DeleteOrphansActionView.as_view(),
     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/$', ContentSourceView.as_view(),
     name='content_sources'),
 url(r'^v2/content/sources/action/(?P<action>[^/]+)/$', ContentSourceView.as_view(),
     name='content_sources_action'),
 url(r'^v2/content/sources/(?P<source_id>[^/]+)/action/(?P<action>[^/]+)/$',
     ContentSourceResourceView.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/types/$', ContentTypesView.as_view(),
     name='content_types'),
 url(r'^v2/content/types/(?P<type_id>[^/]+)/$', ContentTypeResourceView.as_view(),
     name='content_type_resource'),
 url(r'^v2/content/units/(?P<type_id>[^/]+)/$', ContentUnitsCollectionView.as_view(),
     name='content_units_collection'),
 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'),
Ejemplo n.º 12
0
     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(),
Ejemplo n.º 13
0
 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'),
 url(r'^v2/distributors/search/$', RepoDistributorsSearchView.as_view(),
Ejemplo n.º 14
0
 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'),
 url(r'^v2/distributors/search/$', RepoDistributorsSearchView.as_view(),
Ejemplo n.º 15
0
     ConsumerGroupBindingView.as_view(), name='consumer_group_unbind'),
 url(r'^v2/content/actions/delete_orphans/$', DeleteOrphansActionView.as_view(),
     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/$', ContentSourceView.as_view(),
     name='content_sources'),
 url(r'^v2/content/sources/action/(?P<action>[^/]+)/$', ContentSourceView.as_view(),
     name='content_sources_action'),
 url(r'^v2/content/sources/(?P<source_id>[^/]+)/action/(?P<action>[^/]+)/$',
     ContentSourceResourceView.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/types/$', ContentTypesView.as_view(),
     name='content_types'),
 url(r'^v2/content/types/(?P<type_id>[^/]+)/$', ContentTypeResourceView.as_view(),
     name='content_type_resource'),
 url(r'^v2/content/units/(?P<type_id>[^/]+)/$', ContentUnitsCollectionView.as_view(),
     name='content_units_collection'),
 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'),