Skip to content

Commit

Permalink
Unittest for HD profilepic and fix ResourceWarning
Browse files Browse the repository at this point in the history
  • Loading branch information
aandergr committed Jan 17, 2019
1 parent 57892f1 commit b158c57
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 6 additions & 6 deletions instaloader/instaloadercontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,12 @@ def get_iphone_json(self, path: str, params: Dict[str, Any]) -> Dict[str, Any]:
:raises ConnectionException: When query repeatedly failed.
.. versionadded:: 4.2.1"""
tempsession = copy_session(self._session)
tempsession.headers['User-Agent'] = 'Instagram 10.3.2 (iPhone7,2; iPhone OS 9_3_3; en_US; en-US; ' \
'scale=2.00; 750x1334) AppleWebKit/420+'
for header in ['Host', 'Origin', 'X-Instagram-AJAX', 'X-Requested-With']:
tempsession.headers.pop(header, None)
return self.get_json(path, params, 'i.instagram.com', tempsession)
with copy_session(self._session) as tempsession:
tempsession.headers['User-Agent'] = 'Instagram 10.3.2 (iPhone7,2; iPhone OS 9_3_3; en_US; en-US; ' \
'scale=2.00; 750x1334) AppleWebKit/420+'
for header in ['Host', 'Origin', 'X-Instagram-AJAX', 'X-Requested-With']:
tempsession.headers.pop(header, None)
return self.get_json(path, params, 'i.instagram.com', tempsession)

def write_raw(self, resp: Union[bytes, requests.Response], filename: str) -> None:
"""Write raw response data into a file."""
Expand Down
3 changes: 3 additions & 0 deletions test/instaloader_unittests.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ def test_highlights_paging(self):
def test_private_profile_paging(self):
self.post_paging_test(instaloader.Profile.from_username(self.L.context, PRIVATE_PROFILE).get_posts())

def test_profile_pic_download(self):
self.L.download_profile(PUBLIC_PROFILE, profile_pic_only=True)

def test_feed_download(self):
self.L.download_feed_posts(NORMAL_MAX_COUNT)

Expand Down

0 comments on commit b158c57

Please sign in to comment.