Ejemplo n.º 1
0
class AlbumTest(unittest.TestCase):
    def setUp(self):
        self.q = MyDiary(api_key)
        self.album = Album(self.q, "531705626879819")
        self.album.analyze()

    def test_name(self):
        self.assertEqual(self.album["name"], "Prova MyDiary")

    def test_key(self):
        keys = self.album.keys()
        keys = set(keys)
        necessary = set(["date", "id", "name", "photos"])
        self.assertTrue(necessary.issubset(keys))

    def test_photo(self):
        photos = self.album["photos"]
        for photo in photos:
            self.assertEqual(type(photo), Photo)

    def test_comments(self):
        if "comments" in self.album:
            comments = self.album["comments"]
            for comment in comments:
                self.assertEqual(type(comment), dict)
                self.assertTrue("from" in comment)
                self.assertTrue("message" in comment)
                self.assertTrue("id" in comment)
                self.assertEqual(type(comment["from"]["pic_square"].file), file)

    def test_likes(self):
        likes = self.album["likes"]
        for like in likes:
            self.assertEqual(type(like), dict)
            self.assertTrue("name" in like)
            self.assertTrue("id" in like)
            self.assertEqual(type(like["pic_square"].file), file)
Ejemplo n.º 2
0
 def setUp(self):
     self.q = MyDiary(api_key)
     self.album = Album(self.q, "531705626879819")
     self.album.analyze()