Exemplo n.º 1
0
 def test_get_memes(self):
     m1 = mock_make_meme("M1", "hello", "world", "Courier New", 10)
     m2 = mock_make_meme("M2", "Top", "Bottom", "Courier New", 30)
     m3 = mock_make_meme("M3", "F**k", "You", "Courier New", 5)
     memes = api.obj_list(meme.Meme.all().fetch(1000))
     self.assertEqual(len(memes), 3, "make_meme() Error!, results: " + str(memes))
     memes = get_id_list(meme.get_latest_memes(), 'mid')
     self.assertEqual(memes, [m3, m2, m1], "meme.get_latest_memes() Error!, results:" + str(memes))
     memes = get_id_list(meme.get_popular_memes(), 'mid')
     self.assertEqual(memes, [m2, m1, m3], "meme.get_popular_memes() Error!, results:" + str(memes))
Exemplo n.º 2
0
Arquivo: api.py Projeto: niczy/Memegen
 def get(self, type):
     if not type:
         self.error(404)
         return
     if type == 'popular':
         memes = obj_list(meme.get_popular_memes())
         response_json(self, memes)
     if type == 'latest':
         memes = obj_list(meme.get_latest_memes())
         response_json(self, memes)   
     if type == 'byuser':
         uid = self.request.get("uid")