def test_serialize_micro_post(post_factory, user_factory): with patch('szurubooru.func.posts.get_post_thumbnail_url'): posts.get_post_thumbnail_url.return_value \ = 'https://example.com/thumb.png' auth_user = user_factory() post = post_factory() db.session.add(post) db.session.flush() assert posts.serialize_micro_post(post, auth_user) == { 'id': post.post_id, 'thumbnailUrl': 'https://example.com/thumb.png', }
def test_serialize_micro_post(post_factory, user_factory): with patch("szurubooru.func.posts.get_post_thumbnail_url"): posts.get_post_thumbnail_url.return_value = ( "https://example.com/thumb.png") auth_user = user_factory() post = post_factory() db.session.add(post) db.session.flush() assert posts.serialize_micro_post(post, auth_user) == { "id": post.post_id, "thumbnailUrl": "https://example.com/thumb.png", }
def serialize_posts(self) -> Any: return [ post for post in [posts.serialize_micro_post(rel, None) for rel in self.pool.posts] ]