def tagged_with(self, tag_names, **kwargs):
        '''Returns all Posts that are tagged with any of the given tags.'''
        e = get_entity('tag')
        tags = [e(name=tag) for tag in tag_names]
        posts = self.entity(tags=tags)
        r = self._filter(posts, **kwargs)

        return make_entity(self.entity.type_, r.json(), many=True)
 def __init__(self):
     self.entity = assemblers.get_entity(self._entity)
     self.schema = assemblers.get_schema(self.entity._schema)
Beispiel #3
0
def test_get_entity():
    assert issubclass(get_entity('user'), User)
    def get_by_post(self, post_id, **kwargs):
        post = assemblers.get_entity('post')(id=post_id)
        comments = self.entity(post=post)
        r = self._filter(comments, **kwargs)

        return assemblers.make_entity(self._entity, r.json(), many=True)
    def new(self, content, post_id, user, access_token):
        post = assemblers.get_entity('post')(id=post_id)
        comment = self.entity(id=666, content=content, post=post, user=user)
        r = self._new(comment, access_token)

        return assemblers.make_entity(self._entity, r.json())
    def unlike_post(self, user: Entity, post_id: int, access_token: str):
        like = get_entity('likes')(id=post_id)

        return self.delete_from(user, like, access_token)
    def like_post(self, user: Entity, post_id: int, access_token: str):
        like = get_entity('likes')(id=post_id)

        return self.add_to(user, like, access_token)