Пример #1
0
    def test_get_importer_resource_view_nonexistent_importer(self, mock_factory):
        """
        Importer Resource should raise a MissingResource if the specified importer does not exist.
        """
        mock_manager = mock.MagicMock()
        mock_manager.importers.return_value = [{'id': 'mock_importer_1'}, {'id': 'mock_importer_2'}]
        mock_factory.plugin_manager.return_value = mock_manager
        request = mock.MagicMock()

        importer_resource = ImporterResourceView()
        try:
            importer_resource.get(request, 'nonexistent_importer')
        except MissingResource, response:
            pass
Пример #2
0
    def test_get_importer_resource_view_existing_importer(self, mock_factory, mock_resp):
        """
        Importer Resource should return a generate a serialized response with importer data.
        """
        mock_manager = mock.MagicMock()
        mock_manager.importers.return_value = [{'id': 'mock_importer_1'}, {'id': 'mock_importer_2'}]
        mock_factory.plugin_manager.return_value = mock_manager
        request = mock.MagicMock()
        request.get_full_path.return_value = '/mock/path/'

        importer_resource = ImporterResourceView()
        response = importer_resource.get(request, 'mock_importer_2')

        expected_content = {'id': 'mock_importer_2', '_href': '/mock/path/'}
        mock_resp.assert_called_once_with(expected_content)
        self.assertTrue(response is mock_resp.return_value)
Пример #3
0
    def test_get_importer_resource_view_nonexistent_importer(
            self, mock_factory):
        """
        Importer Resource should raise a MissingResource if the specified importer does not exist.
        """
        mock_manager = mock.MagicMock()
        mock_manager.importers.return_value = [{
            'id': 'mock_importer_1'
        }, {
            'id': 'mock_importer_2'
        }]
        mock_factory.plugin_manager.return_value = mock_manager
        request = mock.MagicMock()

        importer_resource = ImporterResourceView()
        try:
            importer_resource.get(request, 'nonexistent_importer')
        except MissingResource, response:
            pass
Пример #4
0
    def test_get_importer_resource_view_existing_importer(
            self, mock_factory, mock_resp):
        """
        Importer Resource should return a generate a serialized response with importer data.
        """
        mock_manager = mock.MagicMock()
        mock_manager.importers.return_value = [{
            'id': 'mock_importer_1'
        }, {
            'id': 'mock_importer_2'
        }]
        mock_factory.plugin_manager.return_value = mock_manager
        request = mock.MagicMock()
        request.get_full_path.return_value = '/mock/path/'

        importer_resource = ImporterResourceView()
        response = importer_resource.get(request, 'mock_importer_2')

        expected_content = {'id': 'mock_importer_2', '_href': '/mock/path/'}
        mock_resp.assert_called_once_with(expected_content)
        self.assertTrue(response is mock_resp.return_value)
Пример #5
0
Файл: urls.py Проект: beav/pulp
        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(),
        name='plugin_distributor_resource'),
    url(r'^v2/plugins/importers/$',
        ImportersView.as_view(),
        name='plugin_importers'),
    url(r'^v2/plugins/importers/(?P<importer_id>[^/]+)/$',
        ImporterResourceView.as_view(),
        name='plugin_importer_resource'),
    url(r'^v2/plugins/types/$', TypesView.as_view(), name='plugin_types'),
    url(r'^v2/plugins/types/(?P<type_id>[^/]+)/$',
        TypeResourceView.as_view(),
        name='plugin_type_resource'),
)
Пример #6
0
 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'),
 url(r'^v2/plugins/distributors/(?P<distributor_id>[^/]+)/$', DistributorResourceView.as_view(),
     name='plugin_distributor_resource'),
 url(r'^v2/plugins/importers/$', ImportersView.as_view(), name='plugin_importers'),
 url(r'^v2/plugins/importers/(?P<importer_id>[^/]+)/$', ImporterResourceView.as_view(),
     name='plugin_importer_resource'),
 url(r'^v2/plugins/types/$', TypesView.as_view(), name='plugin_types'),
 url(r'^v2/plugins/types/(?P<type_id>[^/]+)/$', TypeResourceView.as_view(),
     name='plugin_type_resource'),
 url(r'^v2/repo_groups/$', RepoGroupsView.as_view(), name='repo_groups'),
 url(r'^v2/repo_groups/(?P<repo_group_id>[^/]+)/$', RepoGroupResourceView.as_view(),
     name='repo_group_resource'),
 url(r'^v2/repo_groups/(?P<repo_group_id>[^/]+)/actions/associate/$',
     RepoGroupAssociateView.as_view(), name='repo_group_associate'),
 url(r'^v2/repo_groups/(?P<repo_group_id>[^/]+)/actions/publish/$',
     RepoGroupPublishView.as_view(), name='repo_group_publish'),
 url(r'^v2/repo_groups/(?P<repo_group_id>[^/]+)/actions/unassociate/$',
     RepoGroupUnassociateView.as_view(), name='repo_group_unassociate'),
 url(r'^v2/repo_groups/(?P<repo_group_id>[^/]+)/distributors/$',
     RepoGroupDistributorsView.as_view(), name='repo_group_distributors'),
Пример #7
0
 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'),
 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'),
 url(r'^v2/plugins/distributors/(?P<distributor_id>[^/]+)/$', DistributorResourceView.as_view(),
     name='plugin_distributor_resource'),
 url(r'^v2/plugins/importers/$', ImportersView.as_view(), name='plugin_importers'),
 url(r'^v2/plugins/importers/(?P<importer_id>[^/]+)/$', ImporterResourceView.as_view(),
     name='plugin_importer_resource'),
 url(r'^v2/plugins/types/$', TypesView.as_view(), name='plugin_types'),
 url(r'^v2/plugins/types/(?P<type_id>[^/]+)/$', TypeResourceView.as_view(),
     name='plugin_type_resource'),
 url(r'^v2/repo_groups/$', RepoGroupsView.as_view(), name='repo_groups'),
 url(r'^v2/repo_groups/search/$', RepoGroupSearch.as_view(), name='repo_group_search'),
 url(r'^v2/repo_groups/(?P<repo_group_id>[^/]+)/$', RepoGroupResourceView.as_view(),
     name='repo_group_resource'),
 url(r'^v2/repo_groups/(?P<repo_group_id>[^/]+)/actions/associate/$',
     RepoGroupAssociateView.as_view(), name='repo_group_associate'),
 url(r'^v2/repo_groups/(?P<repo_group_id>[^/]+)/actions/publish/$',
     RepoGroupPublishView.as_view(), name='repo_group_publish'),
 url(r'^v2/repo_groups/(?P<repo_group_id>[^/]+)/actions/unassociate/$',
     RepoGroupUnassociateView.as_view(), name='repo_group_unassociate'),
 url(r'^v2/repo_groups/(?P<repo_group_id>[^/]+)/distributors/$',