InstaloaderContext class for log and low-level IO
This commit is contained in:
parent
8623829696
commit
c350847b50
869
instaloader.py
869
instaloader.py
File diff suppressed because it is too large
Load Diff
@ -25,10 +25,10 @@ class TestInstaloader(unittest.TestCase):
|
||||
self.L = instaloader.Instaloader(download_geotags=instaloader.Tristate.always,
|
||||
download_comments=instaloader.Tristate.always,
|
||||
save_metadata=instaloader.Tristate.always)
|
||||
self.L.raise_all_errors = True
|
||||
self.L.context.raise_all_errors = True
|
||||
|
||||
def tearDown(self):
|
||||
self.L.session.close()
|
||||
self.L.close()
|
||||
os.chdir('/')
|
||||
print("Removing {}".format(self.dir))
|
||||
shutil.rmtree(self.dir)
|
||||
@ -40,13 +40,11 @@ class TestInstaloader(unittest.TestCase):
|
||||
|
||||
@unittest.SkipTest
|
||||
def test_stories_download(self):
|
||||
if not self.L.is_logged_in:
|
||||
self.L.load_session_from_file(OWN_USERNAME)
|
||||
self.L.download_stories()
|
||||
|
||||
@unittest.SkipTest
|
||||
def test_private_profile_download(self):
|
||||
if not self.L.is_logged_in:
|
||||
self.L.load_session_from_file(OWN_USERNAME)
|
||||
self.L.download_profile(PRIVATE_PROFILE, download_stories=True)
|
||||
|
||||
@ -57,12 +55,10 @@ class TestInstaloader(unittest.TestCase):
|
||||
self.L.download_hashtag(HASHTAG, NORMAL_MAX_COUNT)
|
||||
|
||||
def test_feed_download(self):
|
||||
if not self.L.is_logged_in:
|
||||
self.L.load_session_from_file(OWN_USERNAME)
|
||||
self.L.download_feed_posts(NORMAL_MAX_COUNT)
|
||||
|
||||
def test_feed_paging(self):
|
||||
if not self.L.is_logged_in:
|
||||
self.L.load_session_from_file(OWN_USERNAME)
|
||||
for count, post in enumerate(self.L.get_feed_posts()):
|
||||
print(post)
|
||||
@ -70,31 +66,26 @@ class TestInstaloader(unittest.TestCase):
|
||||
break
|
||||
|
||||
def test_saved_download(self):
|
||||
if not self.L.is_logged_in:
|
||||
self.L.load_session_from_file(OWN_USERNAME)
|
||||
self.L.download_saved_posts(NORMAL_MAX_COUNT)
|
||||
|
||||
def test_saved_paging(self):
|
||||
if not self.L.is_logged_in:
|
||||
self.L.load_session_from_file(OWN_USERNAME)
|
||||
for count, post in enumerate(instaloader.Profile(self.L, OWN_USERNAME).get_saved_posts()):
|
||||
for count, post in enumerate(instaloader.Profile(self.L.context, OWN_USERNAME).get_saved_posts()):
|
||||
print(post)
|
||||
if count == PAGING_MAX_COUNT:
|
||||
break
|
||||
|
||||
def test_test_login(self):
|
||||
if not self.L.is_logged_in:
|
||||
self.L.load_session_from_file(OWN_USERNAME)
|
||||
self.assertEqual(OWN_USERNAME, self.L.test_login())
|
||||
|
||||
def test_get_followees(self):
|
||||
if not self.L.is_logged_in:
|
||||
self.L.load_session_from_file(OWN_USERNAME)
|
||||
for f in self.L.get_followees(OWN_USERNAME):
|
||||
print(f['username'])
|
||||
|
||||
def test_get_followers(self):
|
||||
if not self.L.is_logged_in:
|
||||
self.L.load_session_from_file(OWN_USERNAME)
|
||||
for f in self.L.get_followers(OWN_USERNAME):
|
||||
print(f['username'])
|
||||
@ -106,16 +97,15 @@ class TestInstaloader(unittest.TestCase):
|
||||
self.assertEqual(PUBLIC_PROFILE_ID, self.L.get_id_by_username(PUBLIC_PROFILE))
|
||||
|
||||
def test_get_likes(self):
|
||||
if not self.L.is_logged_in:
|
||||
self.L.load_session_from_file(OWN_USERNAME)
|
||||
for post in instaloader.Profile(self.L, OWN_USERNAME).get_posts():
|
||||
for post in instaloader.Profile(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(self.L, PUBLIC_PROFILE).get_posts():
|
||||
post2 = instaloader.Post.from_mediaid(self.L, post.mediaid)
|
||||
for post in instaloader.Profile(self.L.context, PUBLIC_PROFILE).get_posts():
|
||||
post2 = instaloader.Post.from_mediaid(self.L.context, post.mediaid)
|
||||
self.assertEqual(post, post2)
|
||||
break
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user