Example #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))
Example #2
0
 def test_meme_model(self):
     m = meme.Meme(image = "MEME1",
                 template = "TEMPLATE1",
                 like = 0,
                 dislike = 0,
                 original_width = 10,
                 original_height = 20,
                 date = datetime.datetime.now(),
                 captions = ["top_caption", "bottom_caption"])
     m.put()
     memes = api.obj_list(meme.Meme.all().fetch(2))
     self.assertEqual(len(memes), 1, "Model Meme Error! results:" + str(memes))
Example #3
0
def get_id_list(list, field):
    return map(lambda x: x[field], api.obj_list(list))