Ejemplo n.º 1
0
    def test_get_orphan_collection_view(self, mock_factory, mock_resp,
                                        mock_reverse):
        """
        Orphan collection should create a response from a dict of orphan dicts.
        """
        mock_orphans = {
            'orphan1': 1,
            'orphan2': 2,
        }
        mock_orphan_manager = mock.MagicMock()
        mock_orphan_manager.orphans_summary.return_value = mock_orphans
        mock_factory.content_orphan_manager.return_value = mock_orphan_manager
        request = mock.MagicMock()
        mock_reverse.return_value = '/mock/path/'

        orphan_collection = OrphanCollectionView()
        response = orphan_collection.get(request)

        expected_content = {
            'orphan1': {
                'count': 1,
                '_href': '/mock/path/',
            },
            'orphan2': {
                'count': 2,
                '_href': '/mock/path/',
            },
        }
        mock_resp.assert_called_once_with(expected_content)
        self.assertTrue(response is mock_resp.return_value)
Ejemplo n.º 2
0
    def test_get_orphan_collection_view(self, mock_factory, mock_resp, mock_reverse):
        """
        Orphan collection should create a response from a dict of orphan dicts.
        """
        mock_orphans = {
            'orphan1': 1,
            'orphan2': 2,
        }
        mock_orphan_manager = mock.MagicMock()
        mock_orphan_manager.orphans_summary.return_value = mock_orphans
        mock_factory.content_orphan_manager.return_value = mock_orphan_manager
        request = mock.MagicMock()
        mock_reverse.return_value = '/mock/path/'

        orphan_collection = OrphanCollectionView()
        response = orphan_collection.get(request)

        expected_content = {
            'orphan1': {
                'count': 1,
                '_href': '/mock/path/',
            },
            'orphan2': {
                'count': 2,
                '_href': '/mock/path/',
            },
        }
        mock_resp.assert_called_once_with(expected_content)
        self.assertTrue(response is mock_resp.return_value)
Ejemplo n.º 3
0
    def test_delete_orphan_collection_view(self, mock_orphan_manager):
        """
        Delete orphan collection view should call the delete all orphans function.
        """
        request = mock.MagicMock()
        orphan_collection = OrphanCollectionView()
        self.assertRaises(OperationPostponed, orphan_collection.delete,
                          request)

        mock_orphan_manager.delete_all_orphans.apply_async.assert_called_once_with(
            tags=['pulp:content_unit:orphans'])
Ejemplo n.º 4
0
Archivo: urls.py Proyecto: beav/pulp
     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/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(),
Ejemplo n.º 5
0
 url(r'^v2/consumer_groups/(?P<consumer_group_id>[^/]+)/actions/associate/$',
     ConsumerGroupAssociateActionView.as_view(), name='consumer_group_associate'),
 url(r'^v2/consumer_groups/(?P<consumer_group_id>[^/]+)/actions/unassociate/$',
     ConsumerGroupUnassociateActionView.as_view(), name='consumer_group_unassociate'),
 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(),
Ejemplo n.º 6
0
 url(r'^v2/consumer_groups/(?P<consumer_group_id>[^/]+)/actions/associate/$',
     ConsumerGroupAssociateActionView.as_view(), name='consumer_group_associate'),
 url(r'^v2/consumer_groups/(?P<consumer_group_id>[^/]+)/actions/unassociate/$',
     ConsumerGroupUnassociateActionView.as_view(), name='consumer_group_unassociate'),
 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(),