Skip to content

Commit

Permalink
Minor code tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ping committed May 17, 2017
1 parent baa6db0 commit c158911
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 17 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

A Python wrapper for the Instagram private API with no 3rd party dependencies. Supports both the app and web APIs.

![Python 2.7, 3.5](https://img.shields.io/badge/Python-2.7%2C%203.5-3776ab.svg)
[![Release](https://img.shields.io/badge/release-v1.2.8-orange.svg)](https://github.com/ping/instagram_private_api/releases)
[![Docs](https://img.shields.io/badge/docs-readthedocs.io-ff4980.svg)](https://instagram-private-api.readthedocs.io/en/latest/)
![Python 2.7, 3.5](https://img.shields.io/badge/Python-2.7%2C%203.5-3776ab.svg?maxAge=2592000)
[![Release](https://img.shields.io/github/release/ping/instagram_private_api.svg?colorB=ff7043)](https://github.com/ping/instagram_private_api/releases)
[![Docs](https://img.shields.io/badge/docs-readthedocs.io-ff4980.svg?maxAge=2592000)](https://instagram-private-api.readthedocs.io/en/latest/)
[![Build](https://img.shields.io/travis/ping/instagram_private_api.svg)](https://travis-ci.org/ping/instagram_private_api)

## Overview
Expand Down
5 changes: 2 additions & 3 deletions examples/savesettings_logincallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ def to_json(python_object):


def from_json(json_object):
if '__class__' in json_object:
if json_object['__class__'] == 'bytes':
return codecs.decode(json_object['__value__'].encode(), 'base64')
if '__class__' in json_object and json_object['__class__'] == 'bytes':
return codecs.decode(json_object['__value__'].encode(), 'base64')
return json_object


Expand Down
2 changes: 1 addition & 1 deletion instagram_private_api/endpoints/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def broadcast_like(self, broadcast_id, like_count=1):
:param like_count:
:return:
"""
if like_count < 1 or like_count > 5:
if not (1 <= like_count <= 5):
raise ValueError('Invalid like_count')
broadcast_id = str(broadcast_id)
endpoint = 'live/%(broadcast_id)s/like/' % {'broadcast_id': broadcast_id}
Expand Down
2 changes: 1 addition & 1 deletion instagram_private_api/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def iter(self, fields, files):
yield encoder('--{}\r\n'.format(self.boundary))
yield encoder(self.u('Content-Disposition: form-data; name="{}"\r\n').format(key))
yield encoder('\r\n')
if isinstance(value, int) or isinstance(value, float):
if isinstance(value, (int, float)):
value = str(value)
yield encoder(self.u(value))
yield encoder('\r\n')
Expand Down
5 changes: 2 additions & 3 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ def to_json(python_object):


def from_json(json_object):
if '__class__' in json_object:
if json_object['__class__'] == 'bytes':
return codecs.decode(json_object['__value__'].encode(), 'base64')
if '__class__' in json_object and json_object['__class__'] == 'bytes':
return codecs.decode(json_object['__value__'].encode(), 'base64')
return json_object


Expand Down
11 changes: 5 additions & 6 deletions tests/private/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,12 +412,11 @@ def test_post_video_base(self, size, duration, caption='', location=None,
opener_side_effect = [
MockResponse(), # chunk 1
]
if not raise_httperror:
if chunk_count == 4:
opener_side_effect.append(
MockResponse()
)
else:
if not raise_httperror and chunk_count == 4:
opener_side_effect.append(
MockResponse()
)
elif raise_httperror:
opener_side_effect.append(
compat_urllib_error.HTTPError(
'http://localhost', 400, 'Bad Request', {},
Expand Down

0 comments on commit c158911

Please sign in to comment.