Esempio n. 1
0
    def test_get_orphan_type_subcollection(self, mock_factory, mock_resp,
                                           mock_reverse):
        """
        OrphanTypeSubCollection should return a response from a list of dicts, one for each orphan.
        """
        mock_orphan_manager = mock.MagicMock()
        mock_orphan_manager.generate_orphans_by_type_with_unit_keys.return_value = [
            {
                '_id': 'orphan1'
            }, {
                '_id': 'orphan2'
            }
        ]
        mock_factory.content_orphan_manager.return_value = mock_orphan_manager
        request = mock.MagicMock()
        mock_reverse.return_value = '/mock/path/'

        orphan_type_subcollection = OrphanTypeSubCollectionView()
        response = orphan_type_subcollection.get(request, 'mock_type')

        expected_content = [{
            '_id': 'orphan1',
            '_href': '/mock/path/'
        }, {
            '_id': 'orphan2',
            '_href': '/mock/path/'
        }]

        mock_resp.assert_called_once_with(expected_content)
        self.assertTrue(response is mock_resp.return_value)
Esempio n. 2
0
    def test_get_orphan_type_subcollection_with_empty_list(self, mock_factory, mock_resp):
        """
        View should return a response with an empty list when there are no orphans of the type.
        """
        mock_orphan_manager = mock.MagicMock()
        mock_orphan_manager.generate_orphans_by_type_with_unit_keys.return_value = []
        mock_factory.content_orphan_manager.return_value = mock_orphan_manager
        request = mock.MagicMock()

        orphan_type_subcollection = OrphanTypeSubCollectionView()
        response = orphan_type_subcollection.get(request, 'mock_type')

        expected_content = []
        mock_resp.assert_called_once_with(expected_content)
        self.assertTrue(response is mock_resp.return_value)
Esempio n. 3
0
    def test_get_orphan_type_subcollection_with_empty_list(self, mock_factory, mock_resp):
        """
        View should return a response with an empty list when there are no orphans of the type.
        """
        mock_orphan_manager = mock.MagicMock()
        mock_orphan_manager.generate_orphans_by_type_with_unit_keys.return_value = []
        mock_factory.content_orphan_manager.return_value = mock_orphan_manager
        request = mock.MagicMock()

        orphan_type_subcollection = OrphanTypeSubCollectionView()
        response = orphan_type_subcollection.get(request, 'mock_type')

        expected_content = []
        mock_resp.assert_called_once_with(expected_content)
        self.assertTrue(response is mock_resp.return_value)
Esempio n. 4
0
    def test_delete_unknown_type(self, mock_get_unit_key_fields):
        mock_get_unit_key_fields.side_effect = ValueError
        request = mock.MagicMock()

        orphan_type_subcollection = OrphanTypeSubCollectionView()
        self.assertRaises(MissingResource, orphan_type_subcollection.delete,
                          request, 'mock_type')
Esempio n. 5
0
    def test_get_orphan_type_subcollection(self, mock_factory, mock_resp, mock_reverse):
        """
        OrphanTypeSubCollection should return a response from a list of dicts, one for each orphan.
        """
        mock_orphan_manager = mock.MagicMock()
        mock_orphan_manager.generate_orphans_by_type_with_unit_keys.return_value = [
            {'_id': 'orphan1'}, {'_id': 'orphan2'}
        ]
        mock_factory.content_orphan_manager.return_value = mock_orphan_manager
        request = mock.MagicMock()
        mock_reverse.return_value = '/mock/path/'

        orphan_type_subcollection = OrphanTypeSubCollectionView()
        response = orphan_type_subcollection.get(request, 'mock_type')

        expected_content = [{'_id': 'orphan1', '_href': '/mock/path/'},
                            {'_id': 'orphan2', '_href': '/mock/path/'}]

        mock_resp.assert_called_once_with(expected_content)
        self.assertTrue(response is mock_resp.return_value)
Esempio n. 6
0
    def test_delete_orphan_type_subcollection(self, mock_orphan_manager):
        """
        Delete orphans should be called with the correct arguments and OperationPostponed is raised.
        """
        request = mock.MagicMock()

        orphan_type_subcollection = OrphanTypeSubCollectionView()
        self.assertRaises(OperationPostponed, orphan_type_subcollection.delete,
                          request, 'mock_type')

        mock_orphan_manager.delete_orphans_by_type.apply_async.assert_called_once_with(
            ('mock_type', ), tags=['pulp:content_unit:orphans'])
Esempio n. 7
0
File: urls.py Progetto: beav/pulp
     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(),
     name='content_units_collection'),
 url(r'^v2/content/units/(?P<type_id>[^/]+)/(?P<unit_id>[^/]+)/$',
     ContentUnitResourceView.as_view(),
Esempio n. 8
0
     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(),
     name='content_type_resource'),
Esempio n. 9
0
     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(),
     name='content_units_collection'),