def test_post_repo_groups_full_data_set(self, mock_factory, mock_rev, mock_redir, mock_resp): """ Create a repo group using all allowed fields. """ mock_group = { 'id': 'mock_group', 'display_name': 'mock_display', 'description': 'mock_desc', 'repo_ids': ['mock_repo_id'], 'notes': 'mock_notes', 'distributors': ['mock_dist'] } mock_request = mock.MagicMock() mock_request.body = json.dumps(mock_group) mock_rev.return_value = '/mock/path/' mock_rg_manager = mock_factory.repo_group_manager.return_value expected_data = {'id': 'mock_created_group'} mock_rg_manager.create_and_configure_repo_group.return_value = expected_data repo_groups_view = RepoGroupsView() response = repo_groups_view.post(mock_request) expected_data['_href'] = mock_rev() mock_resp.assert_called_once_with(expected_data) mock_redir.assert_called_once_with(mock_resp.return_value, expected_data['_href']) self.assertTrue(response is mock_redir.return_value)
def test_post_repo_groups_only_id(self, mock_factory, mock_reverse, mock_redir, mock_resp): """ Create a repo group using the minimal body. """ mock_request = mock.MagicMock() mock_request.body = json.dumps({'id': 'mock_group'}) mock_reverse.return_value = '/mock/path/' mock_rg_manager = mock_factory.repo_group_manager.return_value mock_rg_manager.create_and_configure_repo_group.return_value = { 'id': 'mock_created_group' } repo_groups_view = RepoGroupsView() response = repo_groups_view.post(mock_request) expected_content = { 'id': 'mock_created_group', '_href': '/mock/path/', 'distributors': [] } mock_resp.assert_called_once_with(expected_content) mock_redir.assert_called_once_with(mock_resp.return_value, expected_content['_href']) self.assertTrue(response is mock_redir.return_value)
def test_post_repo_groups_extra_data(self): """ Create a repo group with an invalid field. """ mock_request = mock.MagicMock() mock_request.body = json.dumps({'id': 'mock_group', 'extra_field': 'extra_data'}) repo_groups_view = RepoGroupsView() try: repo_groups_view.post(mock_request) except pulp_exceptions.InvalidValue, response: pass
def test_post_repo_groups_missing_id(self): """ Create a repo group without an id specified. """ mock_request = mock.MagicMock() mock_request.body = json.dumps({'not_id': 'mock_group'}) repo_groups_view = RepoGroupsView() try: repo_groups_view.post(mock_request) except pulp_exceptions.MissingValue, response: pass
def test_get_repo_groups(self, mock_resp, mock_collection, mock_reverse): """ View should return a list of dicts, one for each repo group. """ mock_collection.return_value.find.return_value = [{'id': 'group_1'}, {'id': 'group_2'}] mock_request = mock.MagicMock() mock_reverse.return_value = '/mock/path/' repo_groups_view = RepoGroupsView() response = repo_groups_view.get(mock_request) expected_content = [{'id': 'group_1', '_href': '/mock/path/'}, {'id': 'group_2', '_href': '/mock/path/'}] mock_resp.assert_called_once_with(expected_content) self.assertTrue(response is mock_resp.return_value)
def test_post_repo_groups_only_id(self, mock_factory, mock_reverse, mock_redir, mock_resp): """ Create a repo group using the minimal body. """ mock_request = mock.MagicMock() mock_request.body = json.dumps({'id': 'mock_group'}) mock_reverse.return_value = '/mock/path/' mock_rg_manager = mock_factory.repo_group_manager.return_value mock_rg_manager.create_and_configure_repo_group.return_value = {'id': 'mock_created_group'} repo_groups_view = RepoGroupsView() response = repo_groups_view.post(mock_request) expected_content = {'id': 'mock_created_group', '_href': '/mock/path/', 'distributors': []} mock_resp.assert_called_once_with(expected_content) mock_redir.assert_called_once_with(mock_resp.return_value, expected_content['_href']) self.assertTrue(response is mock_redir.return_value)
def test_post_repo_groups_full_data_set(self, mock_factory, mock_rev, mock_redir, mock_resp): """ Create a repo group using all allowed fields. """ mock_group = {'id': 'mock_group', 'display_name': 'mock_display', 'description': 'mock_desc', 'repo_ids': ['mock_repo_id'], 'notes': 'mock_notes', 'distributors': ['mock_dist']} mock_request = mock.MagicMock() mock_request.body = json.dumps(mock_group) mock_rev.return_value = '/mock/path/' mock_rg_manager = mock_factory.repo_group_manager.return_value expected_data = {'id': 'mock_created_group'} mock_rg_manager.create_and_configure_repo_group.return_value = expected_data repo_groups_view = RepoGroupsView() response = repo_groups_view.post(mock_request) expected_data['_href'] = mock_rev() mock_resp.assert_called_once_with(expected_data) mock_redir.assert_called_once_with(mock_resp.return_value, expected_data['_href']) self.assertTrue(response is mock_redir.return_value)
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'), 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'),
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'), 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/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'),