def test_delete_removes_authclient(self, authclient, matchers, pyramid_request): pyramid_request.db.delete = create_autospec(pyramid_request.db.delete, return_value=None) ctrl = AuthClientEditController(authclient, pyramid_request) ctrl.delete() pyramid_request.db.delete.assert_called_with(authclient)
def test_delete_removes_authclient(self, authclient, pyramid_request): pyramid_request.db.delete = create_autospec(pyramid_request.db.delete, return_value=None) ctrl = AuthClientEditController(authclient, pyramid_request) ctrl.delete() pyramid_request.db.delete.assert_called_with(authclient)
def test_delete_redirects_to_index(self, authclient, pyramid_request): pyramid_request.db.delete = create_autospec(pyramid_request.db.delete, return_value=None) ctrl = AuthClientEditController(authclient, pyramid_request) response = ctrl.delete() expected_location = pyramid_request.route_url('admin_oauthclients') assert response == redirect_302_to(expected_location)
def test_delete_redirects_to_index(self, authclient, matchers, pyramid_request): pyramid_request.db.delete = create_autospec(pyramid_request.db.delete, return_value=None) ctrl = AuthClientEditController(authclient, pyramid_request) response = ctrl.delete() expected_location = pyramid_request.route_url('admin_oauthclients') assert response == matchers.Redirect302To(expected_location)
def test_update_sets_response_type(self, authclient, form_post, pyramid_request, grant_type, expected_response_type): pyramid_request.POST = form_post pyramid_request.POST['grant_type'] = grant_type ctrl = AuthClientEditController(authclient, pyramid_request) ctrl.update() assert authclient.response_type == expected_response_type
def test_update_updates_authclient(self, authclient, form_post, pyramid_request): form_post['client_id'] = authclient.id form_post['client_secret'] = authclient.secret pyramid_request.POST = form_post ctrl = AuthClientEditController(authclient, pyramid_request) ctx = ctrl.update() assert authclient.name == 'new-name' assert ctx['form'] == self._expected_form(authclient)
def test_update_does_not_update_read_only_fields(self, authclient, form_post, pyramid_request): # Attempt to modify read-only ID and secret fields. old_id = authclient.id old_secret = authclient.secret form_post['client_id'] = 'new-id' form_post['client_secret'] = 'new-secret' pyramid_request.POST = form_post ctrl = AuthClientEditController(authclient, pyramid_request) ctx = ctrl.update() assert authclient.id == old_id assert authclient.secret == old_secret assert ctx['form'] == self._expected_form(authclient)
def test_read_renders_form(self, authclient, pyramid_request): ctrl = AuthClientEditController(authclient, pyramid_request) ctx = ctrl.read() assert ctx['form'] == self._expected_form(authclient)