From dcd16f29c2958fc4d839e7f45c2c4500cbb59b36 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 17 Apr 2018 14:10:27 +0200 Subject: [PATCH] Split tests TestInstaloader{Anonymously,LoggedIn} --- test/instaloader_unittests.py | 119 ++++++++++++++++------------------ 1 file changed, 57 insertions(+), 62 deletions(-) diff --git a/test/instaloader_unittests.py b/test/instaloader_unittests.py index 7cd8a1e..ac14679 100644 --- a/test/instaloader_unittests.py +++ b/test/instaloader_unittests.py @@ -16,7 +16,7 @@ PAGING_MAX_COUNT = 15 PRIVATE_PROFILE = "aandergr" -class TestInstaloader(unittest.TestCase): +class TestInstaloaderAnonymously(unittest.TestCase): def setUp(self): self.dir = tempfile.mkdtemp() @@ -38,84 +38,79 @@ class TestInstaloader(unittest.TestCase): self.L.download_profile(PUBLIC_PROFILE, profile_pic=False, fast_update=True) self.L.download_profile(PUBLIC_PROFILE, profile_pic=False, fast_update=True) - @unittest.SkipTest - def test_stories_download(self): - self.L.load_session_from_file(OWN_USERNAME) - self.L.download_stories() - - @unittest.SkipTest - def test_private_profile_download(self): - self.L.load_session_from_file(OWN_USERNAME) - self.L.download_profile(PRIVATE_PROFILE, download_stories=True) - def test_profile_pic_download(self): self.L.download_profile(PUBLIC_PROFILE, profile_pic_only=True) def test_hashtag_download(self): self.L.download_hashtag(HASHTAG, NORMAL_MAX_COUNT) - def test_feed_download(self): - self.L.load_session_from_file(OWN_USERNAME) - self.L.download_feed_posts(NORMAL_MAX_COUNT) - - def test_feed_paging(self): - self.L.load_session_from_file(OWN_USERNAME) - for count, post in enumerate(self.L.get_feed_posts()): - print(post) - if count == PAGING_MAX_COUNT: - break - - def test_saved_download(self): - self.L.load_session_from_file(OWN_USERNAME) - self.L.download_saved_posts(NORMAL_MAX_COUNT) - - def test_saved_paging(self): - self.L.load_session_from_file(OWN_USERNAME) - for count, post in enumerate(instaloader.Profile.from_username(self.L.context, OWN_USERNAME).get_saved_posts()): - print(post) - if count == PAGING_MAX_COUNT: - break - - def test_test_login(self): - self.L.load_session_from_file(OWN_USERNAME) - self.assertEqual(OWN_USERNAME, self.L.test_login()) - - def test_get_followees(self): - self.L.load_session_from_file(OWN_USERNAME) - profile = instaloader.Profile.from_username(self.L.context, OWN_USERNAME) - for f in profile.get_followees(): - print(f['username']) - - def test_get_followers(self): - self.L.load_session_from_file(OWN_USERNAME) - profile = instaloader.Profile.from_username(self.L.context, OWN_USERNAME) - for f in profile.get_followers(): - print(f['username']) - - def test_get_username_by_id(self): - self.L.load_session_from_file(OWN_USERNAME) - self.assertEqual(PUBLIC_PROFILE.lower(), - instaloader.Profile.from_id(self.L.context, PUBLIC_PROFILE_ID).username) - def test_get_id_by_username(self): self.assertEqual(PUBLIC_PROFILE_ID, instaloader.Profile.from_username(self.L.context, PUBLIC_PROFILE).userid) - def test_get_likes(self): - self.L.load_session_from_file(OWN_USERNAME) - for post in instaloader.Profile.from_username(self.L.context, OWN_USERNAME).get_posts(): - for like in post.get_likes(): - print(like['username']) - break - def test_post_from_mediaid(self): for post in instaloader.Profile.from_username(self.L.context, PUBLIC_PROFILE).get_posts(): post2 = instaloader.Post.from_mediaid(self.L.context, post.mediaid) self.assertEqual(post, post2) break - def test_explore_paging(self): + +class TestInstaloaderLoggedIn(TestInstaloaderAnonymously): + + def setUp(self): + super().setUp() self.L.load_session_from_file(OWN_USERNAME) + + @unittest.SkipTest + def test_stories_download(self): + self.L.download_stories() + + @unittest.SkipTest + def test_private_profile_download(self): + self.L.download_profile(PRIVATE_PROFILE, download_stories=True) + + def test_feed_download(self): + self.L.download_feed_posts(NORMAL_MAX_COUNT) + + def test_feed_paging(self): + for count, post in enumerate(self.L.get_feed_posts()): + print(post) + if count == PAGING_MAX_COUNT: + break + + def test_saved_download(self): + self.L.download_saved_posts(NORMAL_MAX_COUNT) + + def test_saved_paging(self): + for count, post in enumerate(instaloader.Profile.from_username(self.L.context, OWN_USERNAME).get_saved_posts()): + print(post) + if count == PAGING_MAX_COUNT: + break + + def test_test_login(self): + self.assertEqual(OWN_USERNAME, self.L.test_login()) + + def test_get_followees(self): + profile = instaloader.Profile.from_username(self.L.context, OWN_USERNAME) + for f in profile.get_followees(): + print(f['username']) + + def test_get_followers(self): + profile = instaloader.Profile.from_username(self.L.context, OWN_USERNAME) + for f in profile.get_followers(): + print(f['username']) + + def test_get_username_by_id(self): + self.assertEqual(PUBLIC_PROFILE.lower(), + instaloader.Profile.from_id(self.L.context, PUBLIC_PROFILE_ID).username) + + def test_get_likes(self): + for post in instaloader.Profile.from_username(self.L.context, OWN_USERNAME).get_posts(): + for like in post.get_likes(): + print(like['username']) + break + + def test_explore_paging(self): for count, post in enumerate(self.L.get_explore_posts()): print(post) if count == PAGING_MAX_COUNT: