def testBuildNewestLink(self): """ Assert that build_newest_comment_link parses comment links and builds the new location correctly. """ links = [{ "rel": "self", "href": "/api/v1/conversations/161991?comment_id=7050281", "title": "1" }, { "rel": "next", "href": "/api/v1/conversations/161991?comment_id=7050281&offset=25", "title": "2" }, { "rel": "last", "href": "/api/v1/conversations/161991?comment_id=7050281&offset=875", "title": "36" }] response = {"comments": {"links": links}} location = build_newest_comment_link(response) assert location == '/conversations/161991/#comment7050281'
def newest(request, huddle_id): """ Get redirected to the first unread post in a huddle """ try: response = Huddle.newest(request.get_host(), huddle_id, access_token=request.access_token) except APIException as exc: return respond_with_error(request, exc) redirect = build_newest_comment_link(response) return HttpResponseRedirect(redirect)
def newest(request, conversation_id): """ Redirect to the user's first unread post in the conversation. """ try: response = Conversation.newest(request.get_host(), conversation_id, access_token=request.access_token) except APIException as exc: return respond_with_error(request, exc) redirect = build_newest_comment_link(response, request) return HttpResponseRedirect(redirect)
def incontext(request, comment_id): """ Redirect to the user's first unread comment in a list of comments. """ try: response = Comment.incontext(request.get_host(), comment_id, access_token=request.access_token) except APIException as exc: return respond_with_error(request, exc) redirect = build_newest_comment_link(response, request) return HttpResponseRedirect(redirect)
def newest(request, huddle_id): """ Get redirected to the first unread post in a huddle """ try: response = Huddle.newest(request.get_host(), huddle_id, access_token=request.access_token) except APIException as exc: return respond_with_error(request, exc) redirect = build_newest_comment_link(response, request) return HttpResponseRedirect(redirect)
def testBuildNewestLink(self): """ Assert that build_newest_comment_link parses comment links and builds the new location correctly. """ links = [ {"rel": "self", "href": "/api/v1/conversations/161991?comment_id=7050281", "title": "1"}, {"rel": "next", "href": "/api/v1/conversations/161991?comment_id=7050281&offset=25", "title": "2"}, {"rel": "last", "href": "/api/v1/conversations/161991?comment_id=7050281&offset=875", "title": "36"}, ] response = {"comments": {"links": links}} location = build_newest_comment_link(response) assert location == "/conversations/161991/#comment7050281"