def find_by_id(id): # @FIXME: make these exceptions specific to the case # where they can run successfully but do not find # the thing we are looking for. This should be really # easy as I think we just need NoResultFound. from raggregate.queries import submission from raggregate.queries import users from raggregate.queries import epistle as epistle_queries try: return submission.get_story_by_id(id) except: pass if users.get_user_by_id(id): return users.get_user_by_id(id) try: return submission.get_comment_by_id(id) except: pass try: return epistle_queries.get_epistle_by_id(id) except: raise
def find_by_id(id): # @FIXME: make these exceptions specific to the case # where they can run successfully but do not find # the thing we are looking for. This should be really # easy as I think we just need NoResultFound. from raggregate.queries import submission from raggregate.queries import users from raggregate.queries import epistle as epistle_queries try: return submission.get_story_by_id(id) except: pass if users.get_user_by_id(id): return users.get_user_by_id(id) try: return submission.get_comment_by_id(id) except: pass try: return epistle_queries.get_epistle_by_id(id) except: raise
def _assign_epistle_parent(e): #@TODO: REALLY need to put parent_info somewhere smarter, and/or not make this happen so much if e.parent: if e.parent_type == 'story': e.parent_info = submission.get_story_by_id(e.parent) elif e.parent_type == 'comment': e.parent_info = queries.get_comment_by_id(e.parent) elif e.parent_type == 'epistle' or e.parent_type == 'reply': e.parent_info = epistle_queries.get_epistle_by_id(e.parent) return e
def _assign_epistle_parent(e): #@TODO: REALLY need to put parent_info somewhere smarter, and/or not make this happen so much if e.parent: if e.parent_type == 'story': e.parent_info = submission.get_story_by_id(e.parent) elif e.parent_type == 'comment': e.parent_info = queries.get_comment_by_id(e.parent) elif e.parent_type == 'epistle' or e.parent_type == 'reply': e.parent_info = epistle_queries.get_epistle_by_id(e.parent) return e
def test_get_epistle_by_id(self): epistle = self.create_epistle() result = epistle_queries.get_epistle_by_id(epistle.id) assert epistle.id == result.id
def test_get_epistle_by_id(self): epistle = self.create_epistle() result = epistle_queries.get_epistle_by_id(epistle.id) assert epistle.id == result.id