def test_add_invalid_user_to_role(self): """ Test add invalid user to a role. """ request = mock.MagicMock() request.body = json.dumps({'login': None}) role_users = RoleUsersView() try: response = role_users.post(request, 'test-role') except InvalidValue, response: pass
def test_add_user_to_role(self, mock_factory, mock_resp): """ Test add user to a role. """ mock_factory.role_manager.return_value.add_user_to_role.return_value = None request = mock.MagicMock() request.body = json.dumps({'login': '******'}) role_users = RoleUsersView() response = role_users.post(request, 'test-role') mock_resp.assert_called_once_with(None) self.assertTrue(response is mock_resp.return_value)
def test_list_users_beloging_to_role(self, mock_fact, mock_resp): """ Test list Users belonging to a role. """ resp = {'login': '******', 'name': 'bar'} expected_cont = {'login': '******', 'name': 'bar'} mock_fact.user_query_manager.return_value.find_users_belonging_to_role.return_value = resp request = mock.MagicMock() role_users = RoleUsersView() response = role_users.get(request, 'test-role') mock_resp.assert_called_once_with(expected_cont) self.assertTrue(response is mock_resp.return_value)
def test_list_users_beloging_to_role(self, mock_ctrl, mock_fact, mock_resp): """ Test list Users belonging to a role. """ resp = {'login': '******', 'name': 'bar'} expected_cont = {'login': '******', 'name': 'bar'} mock_ctrl.find_users_belonging_to_role.return_value = resp request = mock.MagicMock() role_users = RoleUsersView() response = role_users.get(request, 'test-role') mock_resp.assert_called_once_with(expected_cont) self.assertTrue(response is mock_resp.return_value)
url(r'^v2/repositories/(?P<repo_id>[^/]+)/distributors/(?P<distributor_id>[^/]+)/$', RepoDistributorResourceView.as_view(), name='repo_distributor_resource'), url(r'^v2/repositories/(?P<repo_id>[^/]+)/distributors/(?P<distributor_id>[^/]+)/schedules/publish/$', RepoPublishSchedulesView.as_view(), name='repo_publish_schedules'), url(r'^v2/repositories/(?P<repo_id>[^/]+)/distributors/(?P<distributor_id>[^/]+)/schedules/publish/(?P<schedule_id>[^/]+)/$', RepoPublishScheduleResourceView.as_view(), name='repo_publish_schedule_resource'), url(r'^v2/repositories/(?P<repo_id>[^/]+)/history/sync/$', RepoSyncHistory.as_view(), name='repo_sync_history'), url(r'^v2/repositories/(?P<repo_id>[^/]+)/history/publish/(?P<distributor_id>[^/]+)/$', RepoPublishHistory.as_view(), name='repo_publish_history'), url(r'^v2/repositories/(?P<repo_id>[^/]+)/actions/sync/$', RepoSync.as_view(), name='repo_sync'), url(r'^v2/repositories/(?P<repo_id>[^/]+)/actions/publish/$', RepoPublish.as_view(), name='repo_publish'), url(r'^v2/repositories/(?P<dest_repo_id>[^/]+)/actions/associate/$', RepoAssociate.as_view(), name='repo_associate'), url(r'^v2/repositories/(?P<repo_id>[^/]+)/actions/unassociate/$', RepoUnassociate.as_view(), name='repo_unassociate'), url(r'^v2/repositories/(?P<repo_id>[^/]+)/actions/import_upload/$', RepoImportUpload.as_view(), name='repo_import_upload'), url(r'^v2/roles/$', RolesView.as_view(), name='roles'), url(r'^v2/roles/(?P<role_id>[^/]+)/$', RoleResourceView.as_view(), name='role_resource'), url(r'^v2/roles/(?P<role_id>[^/]+)/users/$', RoleUsersView.as_view(), name='role_users'), url(r'^v2/roles/(?P<role_id>[^/]+)/users/(?P<login>[^/]+)/$', RoleUserView.as_view(), name='role_user'), url(r'^v2/status/$', StatusView.as_view(), name='status'), url(r'^v2/tasks/$', TaskCollectionView.as_view(), name='task_collection'), url(r'^v2/tasks/(?P<task_id>[^/]+)/$', TaskResourceView.as_view(), name='task_resource'), url(r'^v2/users/$', UsersView.as_view(), name='users'), url(r'^v2/users/(?P<login>[^/]+)/$', UserResourceView.as_view(), name='user_resource') )
name='repo_publish'), url(r'^v2/repositories/(?P<dest_repo_id>[^/]+)/actions/associate/$', RepoAssociate.as_view(), name='repo_associate'), url(r'^v2/repositories/(?P<repo_id>[^/]+)/actions/unassociate/$', RepoUnassociate.as_view(), name='repo_unassociate'), url(r'^v2/repositories/(?P<repo_id>[^/]+)/actions/import_upload/$', RepoImportUpload.as_view(), name='repo_import_upload'), url(r'^v2/roles/$', RolesView.as_view(), name='roles'), url(r'^v2/roles/(?P<role_id>[^/]+)/$', RoleResourceView.as_view(), name='role_resource'), url(r'^v2/roles/(?P<role_id>[^/]+)/users/$', RoleUsersView.as_view(), name='role_users'), url(r'^v2/roles/(?P<role_id>[^/]+)/users/(?P<login>[^/]+)/$', RoleUserView.as_view(), name='role_user'), url(r'^v2/status/$', StatusView.as_view(), name='status'), url(r'^v2/tasks/$', tasks.TaskCollectionView.as_view(), name='task_collection'), url(r'^v2/tasks/search/$', tasks.TaskSearchView.as_view(), name='task_search'), url(r'^v2/tasks/(?P<task_id>[^/]+)/$', tasks.TaskResourceView.as_view(), name='task_resource'), url(r'^v2/users/$', users.UsersView.as_view(), name='users'),
RepoPublishSchedulesView.as_view(), name='repo_publish_schedules'), url(r'^v2/repositories/(?P<repo_id>[^/]+)/distributors/(?P<distributor_id>[^/]+)/schedules/publish/(?P<schedule_id>[^/]+)/$', RepoPublishScheduleResourceView.as_view(), name='repo_publish_schedule_resource'), url(r'^v2/repositories/(?P<repo_id>[^/]+)/history/sync/$', RepoSyncHistory.as_view(), name='repo_sync_history'), url(r'^v2/repositories/(?P<repo_id>[^/]+)/history/publish/(?P<distributor_id>[^/]+)/$', RepoPublishHistory.as_view(), name='repo_publish_history'), url(r'^v2/repositories/(?P<repo_id>[^/]+)/actions/sync/$', RepoSync.as_view(), name='repo_sync'), url(r'^v2/repositories/(?P<repo_id>[^/]+)/actions/publish/$', RepoPublish.as_view(), name='repo_publish'), url(r'^v2/repositories/(?P<dest_repo_id>[^/]+)/actions/associate/$', RepoAssociate.as_view(), name='repo_associate'), url(r'^v2/repositories/(?P<repo_id>[^/]+)/actions/unassociate/$', RepoUnassociate.as_view(), name='repo_unassociate'), url(r'^v2/repositories/(?P<repo_id>[^/]+)/actions/import_upload/$', RepoImportUpload.as_view(), name='repo_import_upload'), url(r'^v2/roles/$', RolesView.as_view(), name='roles'), url(r'^v2/roles/(?P<role_id>[^/]+)/$', RoleResourceView.as_view(), name='role_resource'), url(r'^v2/roles/(?P<role_id>[^/]+)/users/$', RoleUsersView.as_view(), name='role_users'), url(r'^v2/roles/(?P<role_id>[^/]+)/users/(?P<login>[^/]+)/$', RoleUserView.as_view(), name='role_user'), url(r'^v2/status/$', StatusView.as_view(), name='status'), url(r'^v2/tasks/$', tasks.TaskCollectionView.as_view(), name='task_collection'), url(r'^v2/tasks/search/$', tasks.TaskSearchView.as_view(), name='task_search'), url(r'^v2/tasks/(?P<task_id>[^/]+)/$', tasks.TaskResourceView.as_view(), name='task_resource'), url(r'^v2/users/$', users.UsersView.as_view(), name='users'), url(r'^v2/users/search/$', users.UserSearchView.as_view(), name='user_search'), url(r'^v2/users/(?P<login>[^/]+)/$', users.UserResourceView.as_view(), name='user_resource') )