def test_get_orphan_resource(self, mock_factory, mock_resp): """ Test get OrphanResourceView, which should return a dict describing an orphan. """ mock_orphan_manager = mock.MagicMock() mock_orphan_manager.get_orphan.return_value = {'_id': 'orphan'} mock_factory.content_orphan_manager.return_value = mock_orphan_manager request = mock.MagicMock() request.get_full_path.return_value = '/mock/path/' orphan_resource = OrphanResourceView() response = orphan_resource.get(request, 'mock_type', 'mock_id') expected_content = {'_id': 'orphan', '_href': '/mock/path/'} mock_resp.assert_called_once_with(expected_content) self.assertTrue(response is mock_resp.return_value)
def test_get_orphan_resource(self, mock_factory, mock_resp): """ Test get OrphanResourceView, which should return a dict describing an orphan. """ mock_orphan_manager = mock.MagicMock() mock_orphan_manager.get_orphan.return_value = {'_id': 'orphan'} mock_factory.content_orphan_manager.return_value = mock_orphan_manager request = mock.MagicMock() request.get_full_path.return_value = '/mock/path/' orphan_resource = OrphanResourceView() response = orphan_resource.get(request, 'mock_type', 'mock_id') expected_content = {'_id': 'orphan', '_href': '/mock/path/'} mock_resp.assert_called_once_with(expected_content) self.assertTrue(response is mock_resp.return_value)
def test_delete_orphan_resource(self, mock_orphan_manager, mock_orphan): """ OrphanResourceView should call delete orphans by id and raise OperationPostponed. """ request = mock.MagicMock() orphan_resource = OrphanResourceView() self.assertRaises(OperationPostponed, orphan_resource.delete, request, 'mock_type', 'mock_id') mock_orphan_manager.delete_orphans_by_id.apply_async.assert_called_once_with( ([{'content_type_id': 'mock_type', 'unit_id': 'mock_id'}],), tags=['pulp:content_unit:orphans'] ) mock_orphan.return_value.get_orphan.assert_called_once_with('mock_type', 'mock_id')
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/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(),
url(r'^v2/consumer_groups/(?P<consumer_group_id>[^/]+)/actions/content/(?P<action>[^/]+)/$', ConsumerGroupContentActionView.as_view(), name='consumer_group_content'), url(r'^v2/consumer_groups/(?P<consumer_group_id>[^/]+)/bindings/$', ConsumerGroupBindingsView.as_view(), name='consumer_group_bind'), url(r'^v2/consumer_groups/(?P<consumer_group_id>[^/]+)' + r'/bindings/(?P<repo_id>[^/]+)/(?P<distributor_id>[^/]+)/$', 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>[^/]+)/$',
url(r'^v2/consumer_groups/(?P<consumer_group_id>[^/]+)/actions/content/(?P<action>[^/]+)/$', ConsumerGroupContentActionView.as_view(), name='consumer_group_content'), url(r'^v2/consumer_groups/(?P<consumer_group_id>[^/]+)/bindings/$', ConsumerGroupBindingsView.as_view(), name='consumer_group_bind'), url(r'^v2/consumer_groups/(?P<consumer_group_id>[^/]+)' + r'/bindings/(?P<repo_id>[^/]+)/(?P<distributor_id>[^/]+)/$', 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/$', 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>[^/]+)/$',