Esempio n. 1
0
    def test_get_content_unit_resource_view_missing_content(self, mock_factory, mock_resp):
        """
        Test ContentUnitResourceView when the requested unit is not found.
        """
        mock_cqm = mock.MagicMock()
        mock_cqm.get_content_unit_by_id.side_effect = MissingResource()
        mock_factory.content_query_manager.return_value = mock_cqm
        request = mock.MagicMock()

        content_unit_resource_view = ContentUnitResourceView()
        response = content_unit_resource_view.get(request, 'mock_type', 'mock_unit')

        msg = _('No content unit resource: mock_unit')
        mock_resp.assert_called_once_with(msg, response_class=HttpResponseNotFound)
        self.assertTrue(response is mock_resp.return_value)
Esempio n. 2
0
    def test_get_content_unit_resource_view_missing_content(self, mock_factory, mock_resp):
        """
        Test ContentUnitResourceView when the requested unit is not found.
        """
        mock_cqm = mock.MagicMock()
        mock_cqm.get_content_unit_by_id.side_effect = MissingResource()
        mock_factory.content_query_manager.return_value = mock_cqm
        request = mock.MagicMock()

        content_unit_resource_view = ContentUnitResourceView()
        response = content_unit_resource_view.get(request, 'mock_type', 'mock_unit')

        msg = _('No content unit resource: mock_unit')
        mock_resp.assert_called_once_with(msg, response_class=HttpResponseNotFound)
        self.assertTrue(response is mock_resp.return_value)
Esempio n. 3
0
    def test_get_content_unit_resource_view(self, mock_factory, mock_serializers,
                                            mock_resp):
        """
        Test ContentUnitResourceView when the requested unit is found.
        """

        mock_cqm = mock.MagicMock()
        mock_cqm.get_content_unit_by_id.return_value = {}
        mock_factory.content_query_manager.return_value = mock_cqm
        request = mock.MagicMock()

        mock_serializers.content_unit_obj.return_value = {}
        mock_serializers.content_unit_child_link_objs.return_value = {'child': 1}

        content_unit_resource_view = ContentUnitResourceView()
        response = content_unit_resource_view.get(request, 'mock_type', 'mock_unit')

        expected_content = {'children': {'child': 1}}
        mock_resp.assert_called_once_with(expected_content)
        self.assertTrue(response is mock_resp.return_value)
Esempio n. 4
0
    def test_get_content_unit_resource_view(self, mock_factory, mock_serializers,
                                            mock_resp):
        """
        Test ContentUnitResourceView when the requested unit is found.
        """

        mock_cqm = mock.MagicMock()
        mock_cqm.get_content_unit_by_id.return_value = {}
        mock_factory.content_query_manager.return_value = mock_cqm
        request = mock.MagicMock()

        mock_serializers.content_unit_obj.return_value = {}
        mock_serializers.content_unit_child_link_objs.return_value = {'child': 1}

        content_unit_resource_view = ContentUnitResourceView()
        response = content_unit_resource_view.get(request, 'mock_type', 'mock_unit')

        expected_content = {'children': {'child': 1}}
        mock_resp.assert_called_once_with(expected_content)
        self.assertTrue(response is mock_resp.return_value)
Esempio n. 5
0
File: urls.py Progetto: beav/pulp
     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/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/(?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/plugins/distributors/$',
     DistributorsView.as_view(),
     name='plugin_distributors'),
 url(r'^v2/plugins/distributors/(?P<distributor_id>[^/]+)/$',
     DistributorResourceView.as_view(),
Esempio n. 6
0
 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'),
 url(r'^v2/content/uploads/(?P<upload_id>[^/]+)/(?P<offset>[^/]+)/$',
     UploadSegmentResourceView.as_view(), name='content_upload_segment_resource'),
 url(r'^v2/events/$', EventView.as_view(), name='events'),
 url(r'^v2/events/(?P<event_listener_id>[^/]+)/$', EventResourceView.as_view(), name='event_resource'),
 url(r'^v2/permissions/$', PermissionView.as_view(), name='permissions'),
 url(r'^v2/permissions/actions/grant_to_role/$', GrantToRoleView.as_view(), name='grant_to_role'),
 url(r'^v2/permissions/actions/grant_to_user/$', GrantToUserView.as_view(), name='grant_to_user'),
 url(r'^v2/permissions/actions/revoke_from_role/$', RevokeFromRoleView.as_view(), name='revoke_from_role'),
 url(r'^v2/permissions/actions/revoke_from_user/$', RevokeFromUserView.as_view(), name='revoke_from_user'),
 url(r'^v2/plugins/distributors/$', DistributorsView.as_view(), name='plugin_distributors'),
Esempio n. 7
0
 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(),
     name='distributor_search'),
 url(r'^v2/events/$', EventView.as_view(), name='events'),
 url(r'^v2/events/(?P<event_listener_id>[^/]+)/$', EventResourceView.as_view(), name='event_resource'),
 url(r'^v2/permissions/$', PermissionView.as_view(), name='permissions'),
 url(r'^v2/permissions/actions/grant_to_role/$', GrantToRoleView.as_view(), name='grant_to_role'),
 url(r'^v2/permissions/actions/grant_to_user/$', GrantToUserView.as_view(), name='grant_to_user'),
 url(r'^v2/permissions/actions/revoke_from_role/$', RevokeFromRoleView.as_view(), name='revoke_from_role'),