def test_post_uploads_collection_view(self, mock_factory, mock_reverse, mock_resp, mock_redirect): """ View post should return a response that contains data for a new upload. """ mock_upload_manager = mock.MagicMock() mock_upload_manager.initialize_upload.return_value = 'mock_id' mock_factory.content_upload_manager.return_value = mock_upload_manager request = mock.MagicMock() request.body = None mock_reverse.return_value = '/mock/path/' content_types_view = UploadsCollectionView() response = content_types_view.post(request) self.assertTrue(mock_upload_manager.initialize_upload.called) mock_resp.assert_called_once_with({ 'upload_id': 'mock_id', '_href': '/mock/path/' }) mock_redirect.assert_called_once_with(mock_resp.return_value, '/mock/path/') self.assertTrue(response is mock_redirect.return_value)
def test_get_uploads_collection_view(self, mock_factory, mock_resp): """ View should return an response that contains a serialized dict with a list of upload_ids. """ mock_upload_manager = mock.MagicMock() mock_upload_manager.list_upload_ids.return_value = ['mock_upload_1', 'mock_upload_2'] mock_factory.content_upload_manager.return_value = mock_upload_manager request = mock.MagicMock() content_types_view = UploadsCollectionView() response = content_types_view.get(request) expected_content = {'upload_ids': ['mock_upload_1', 'mock_upload_2']} mock_resp.assert_called_once_with(expected_content) self.assertTrue(response is mock_resp.return_value)
def test_post_uploads_collection_view(self, mock_factory, mock_reverse, mock_resp, mock_redirect): """ View post should return a response that contains data for a new upload. """ mock_upload_manager = mock.MagicMock() mock_upload_manager.initialize_upload.return_value = 'mock_id' mock_factory.content_upload_manager.return_value = mock_upload_manager request = mock.MagicMock() request.body = None mock_reverse.return_value = '/mock/path/' content_types_view = UploadsCollectionView() response = content_types_view.post(request) self.assertTrue(mock_upload_manager.initialize_upload.called) mock_resp.assert_called_once_with({'upload_id': 'mock_id', '_href': '/mock/path/'}) mock_redirect.assert_called_once_with(mock_resp.return_value, '/mock/path/') self.assertTrue(response is mock_redirect.return_value)
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'), 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'),
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/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'), 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(),