def post(self): """ Save the Posts for the given User, and delete old Posts :param str channel: User name, which posts we will save """ channel = self.request.get('channel') graph = facebook.GraphAPI(self.current_user.access_token) profile = graph.get_object("me") logging.info(str(profile)) posts = None try: posts = graph.get_object(channel+"/posts", limit=20) except Exception as e: logging.info(str(e)) # else: # logging.info(posts["data"]) Posts.refresh_db(posts["data"]) self.show_main()
def test_get_posts(self): Posts.refresh_db(facebook_api_data.resp1["data"]) posts = Posts.get_posts(10) self.assertEqual(len(posts), 10) self.assertIn('La Grande Bellezza', posts[0]["message"])
def test_refresh_db(self): Posts.refresh_db(facebook_api_data.resp1["data"]) self.assertEqual(Posts.query().count(), 10) Posts.refresh_db(facebook_api_data.resp2["data"]) self.assertEqual(Posts.query().count(), 1)