Example #1
0
    def test_post_repo_group_distributors(self, mock_factory, mock_resp,
                                          mock_redir, mock_reverse):
        """
        Create a new repo group distributor.
        """
        mock_request = mock.MagicMock()
        mock_request.body = json.dumps({
            'distributor_type_id': 'mock_type',
            'distributor_config': 'mock_conf',
            'distributor_id': 'mock_id',
        })
        mock_dist_manager = mock_factory.repo_group_distributor_manager.return_value
        mock_dist_manager.add_distributor.return_value = {'id': 'dist1'}
        mock_reverse.return_value = '/mock/path/'

        repo_group_distributors = RepoGroupDistributorsView()
        response = repo_group_distributors.post(mock_request, 'mock_group_id')

        expected_content = {'id': 'dist1', '_href': '/mock/path/'}
        mock_resp.assert_called_once_with(expected_content)
        mock_redir.assert_called_once_with(mock_resp.return_value,
                                           mock_reverse.return_value)
        self.assertTrue(response is mock_redir.return_value)
        mock_dist_manager.add_distributor.assert_called_once_with(
            'mock_group_id', 'mock_type', 'mock_conf', 'mock_id')
Example #2
0
    def test_get_repo_group_distributors(self, mock_factory, mock_resp,
                                         mock_reverse):
        """
        Get all distributors for a repo group.
        """
        mock_request = mock.MagicMock()
        mock_dist_manager = mock_factory.repo_group_distributor_manager.return_value
        mock_dist_manager.find_distributors.return_value = [{
            'id': 'dist1'
        }, {
            'id': 'dist2'
        }]
        mock_reverse.return_value = '/mock/path/'

        repo_group_distributors = RepoGroupDistributorsView()
        response = repo_group_distributors.get(mock_request, 'mock_group_id')

        expected_content = [{
            'id': 'dist1',
            '_href': '/mock/path/'
        }, {
            'id': 'dist2',
            '_href': '/mock/path/'
        }]
        mock_resp.assert_called_once_with(expected_content)
        self.assertTrue(response is mock_resp.return_value)
        mock_dist_manager.find_distributors.assert_called_once_with(
            'mock_group_id')
Example #3
0
    def test_get_repo_group_distributors(self, mock_factory, mock_resp, mock_reverse):
        """
        Get all distributors for a repo group.
        """
        mock_request = mock.MagicMock()
        mock_dist_manager = mock_factory.repo_group_distributor_manager.return_value
        mock_dist_manager.find_distributors.return_value = [{'id': 'dist1'}, {'id': 'dist2'}]
        mock_reverse.return_value = '/mock/path/'

        repo_group_distributors = RepoGroupDistributorsView()
        response = repo_group_distributors.get(mock_request, 'mock_group_id')

        expected_content = [{'id': 'dist1', '_href': '/mock/path/'},
                            {'id': 'dist2', '_href': '/mock/path/'}]
        mock_resp.assert_called_once_with(expected_content)
        self.assertTrue(response is mock_resp.return_value)
        mock_dist_manager.find_distributors.assert_called_once_with('mock_group_id')
Example #4
0
    def test_post_repo_group_distributors(self, mock_factory, mock_resp, mock_redir, mock_reverse):
        """
        Create a new repo group distributor.
        """
        mock_request = mock.MagicMock()
        mock_request.body = json.dumps({
            'distributor_type_id': 'mock_type',
            'distributor_config': 'mock_conf',
            'distributor_id': 'mock_id',
        })
        mock_dist_manager = mock_factory.repo_group_distributor_manager.return_value
        mock_dist_manager.add_distributor.return_value = {'id': 'dist1'}
        mock_reverse.return_value = '/mock/path/'

        repo_group_distributors = RepoGroupDistributorsView()
        response = repo_group_distributors.post(mock_request, 'mock_group_id')

        expected_content = {'id': 'dist1', '_href': '/mock/path/'}
        mock_resp.assert_called_once_with(expected_content)
        mock_redir.assert_called_once_with(mock_resp.return_value, mock_reverse.return_value)
        self.assertTrue(response is mock_redir.return_value)
        mock_dist_manager.add_distributor.assert_called_once_with(
            'mock_group_id', 'mock_type', 'mock_conf', 'mock_id'
        )
Example #5
0
 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'),
 url(r'^v2/repo_groups/(?P<repo_group_id>[^/]+)/distributors/(?P<distributor_id>[^/]+)/$',
     RepoGroupDistributorResourceView.as_view(), name='repo_group_distributor_resource'),
 url(r'^v2/repositories/$', ReposView.as_view(), name='repos'),
 url(r'^v2/repositories/actions/content/regenerate_applicability/$',
     ContentApplicabilityRegenerationView.as_view(), name='repo_content_app_regen'),
 url(r'^v2/repositories/(?P<repo_id>[^/]+)/$', RepoResourceView.as_view(), name='repo_resource'),
 url(r'^v2/repositories/(?P<repo_id>[^/]+)/importers/$', RepoImportersView.as_view(),
     name='repo_importers'),
 url(r'^v2/repositories/(?P<repo_id>[^/]+)/importers/(?P<importer_id>[^/]+)/$',
     RepoImporterResourceView.as_view(), name='repo_importer_resource'),
 url(r'^v2/repositories/(?P<repo_id>[^/]+)/importers/(?P<importer_id>[^/]+)/schedules/sync/$',
     RepoSyncSchedulesView.as_view(), name='repo_sync_schedules'),
 url(r'^v2/repositories/(?P<repo_id>[^/]+)/importers/(?P<importer_id>[^/]+)/schedules/sync/(?P<schedule_id>[^/]+)/$',
     RepoSyncScheduleResourceView.as_view(), name='repo_sync_schedule_resource'),
 url(r'^v2/repositories/(?P<repo_id>[^/]+)/distributors/$', RepoDistributorsView.as_view(),
Example #6
0
     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/$',
     RepoGroupDistributorsView.as_view(),
     name='repo_group_distributors'),
 url(r'^v2/repo_groups/(?P<repo_group_id>[^/]+)/distributors/(?P<distributor_id>[^/]+)/$',
     RepoGroupDistributorResourceView.as_view(),
     name='repo_group_distributor_resource'),
 url(r'^v2/repositories/$', ReposView.as_view(), name='repos'),
 url(r'^v2/repositories/search/$', RepoSearch.as_view(),
     name='repo_search'),
 url(r'^v2/repositories/actions/content/regenerate_applicability/$',
     ContentApplicabilityRegenerationView.as_view(),
     name='repo_content_app_regen'),
 url(r'^v2/repositories/(?P<repo_id>[^/]+)/$',
     RepoResourceView.as_view(),
     name='repo_resource'),
 url(r'^v2/repositories/(?P<repo_id>[^/]+)/search/units/$',
     RepoUnitSearch.as_view(),
Example #7
0
     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/$',
     RepoGroupDistributorsView.as_view(), name='repo_group_distributors'),
 url(r'^v2/repo_groups/(?P<repo_group_id>[^/]+)/distributors/(?P<distributor_id>[^/]+)/$',
     RepoGroupDistributorResourceView.as_view(), name='repo_group_distributor_resource'),
 url(r'^v2/repositories/$', ReposView.as_view(), name='repos'),
 url(r'^v2/repositories/search/$', RepoSearch.as_view(), name='repo_search'),
 url(r'^v2/repositories/actions/content/regenerate_applicability/$',
     ContentApplicabilityRegenerationView.as_view(), name='repo_content_app_regen'),
 url(r'^v2/repositories/(?P<repo_id>[^/]+)/$', RepoResourceView.as_view(), name='repo_resource'),
 url(r'^v2/repositories/(?P<repo_id>[^/]+)/search/units/$', RepoUnitSearch.as_view(), name='repo_unit_search'),
 url(r'^v2/repositories/(?P<repo_id>[^/]+)/importers/$', RepoImportersView.as_view(),
     name='repo_importers'),
 url(r'^v2/repositories/(?P<repo_id>[^/]+)/importers/(?P<importer_id>[^/]+)/$',
     RepoImporterResourceView.as_view(), name='repo_importer_resource'),
 url(r'^v2/repositories/(?P<repo_id>[^/]+)/importers/(?P<importer_id>[^/]+)/schedules/sync/$',
     RepoSyncSchedulesView.as_view(), name='repo_sync_schedules'),
 url(r'^v2/repositories/(?P<repo_id>[^/]+)/importers/(?P<importer_id>[^/]+)/schedules/sync/(?P<schedule_id>[^/]+)/$',