Commit 0e0198dd authored by fendouai's avatar fendouai

fix tests in python3

parent ca2cb59a
.. image:: https://travis-ci.org/jpush/jpush-api-python-client.svg?branch=master
:target: https://travis-ci.org/jpush/jpush-api-python-client
.. image:: https://badge.fury.io/gh/jpush%2Fjpush-api-python-client.svg
:target: http://badge.fury.io/gh/jpush%2Fjpush-api-python-client
.. image:: https://badge.fury.io/py/jpush.svg
:target: http://badge.fury.io/py/jpush
.. image:: https://pypip.in/download/jpush/badge.svg
:target: https://pypi.python.org/pypi/jpush/
:alt: Downloads
======================= =======================
JPush API Python Client JPush API Python Client
======================= =======================
JPush's officially supported Python client library for accessing JPush APIs. JPush's officially supported Python client library for accessing JPush APIs.
JPush Rest API Documents: `http://docs.jpush.io/server/rest_api_v3_push/ <http://docs.jpush.io/server/rest_api_v3_push/>`_ JPush Rest API Documents: http://docs.jpush.io/server/rest_api_v3_push/
You can download the latest release file here: `Releases <https://github.com/jpush/jpush-api-python-client/releases>`_ You can download the latest release file here: https://github.com/jpush/jpush-api-python-client/releases
------------ ------------
Installation Installation
------------ ------------
To install jpush-api-python-client, simply: To install jpush-api-python-client, simply:
.. code-block:: sh
$ sudo pip install jpush $ sudo pip install jpush
or alternatively install via easy_install: or alternatively install via easy_install:
.. code-block:: sh
$ sudo easy_install jpush $ sudo easy_install jpush
or from source: or from source:
.. code-block:: sh
$ sudo python setup.py install $ sudo python setup.py install
------- -------
...@@ -48,14 +32,12 @@ with Python. ...@@ -48,14 +32,12 @@ with Python.
To run jpush-api-python-client tests, simply: To run jpush-api-python-client tests, simply:
.. code-block:: sh
$ nosetests tests/push tests/devices --verbosity=2 $ nosetests tests/push tests/devices --verbosity=2
-------- --------
Examples Examples
-------- --------
You can see more examples in `examples <https://github.com/jpush/jpush-api-python-client/blob/master/examples>`_ You can see more examples in https://github.com/jpush/jpush-api-python-client/blob/master/examples
Simple iOS Push Simple iOS Push
--------------- ---------------
...@@ -85,8 +67,3 @@ Questions ...@@ -85,8 +67,3 @@ Questions
-------- --------
The best place to ask questions is our community site: The best place to ask questions is our community site:
http://community.jpush.cn/ http://community.jpush.cn/
--------
Thanks to
--------
`crystal-wei <https://github.com/crystal-wei>`_ for reporting the jpush-api-python-client issues;
...@@ -30,13 +30,13 @@ class TestAudience(unittest.TestCase): ...@@ -30,13 +30,13 @@ class TestAudience(unittest.TestCase):
response = push.send() response = push.send()
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
except common.Unauthorized, e: except common.Unauthorized as e:
self.assertFalse(isinstance(e, common.Unauthorized)) self.assertFalse(isinstance(e, common.Unauthorized))
raise common.Unauthorized("Unauthorized") raise common.Unauthorized("Unauthorized")
except common.APIConnectionException, e: except common.APIConnectionException as e:
self.assertFalse(isinstance(e, common.APIConnectionException)) self.assertFalse(isinstance(e, common.APIConnectionException))
raise common.APIConnectionException("conn") raise common.APIConnectionException("conn")
except common.JPushFailure, e: except common.JPushFailure as e:
self.assertFalse(isinstance(e, common.JPushFailure)) self.assertFalse(isinstance(e, common.JPushFailure))
print ("JPushFailure") print ("JPushFailure")
except: except:
......
...@@ -43,13 +43,13 @@ class TestMessage(unittest.TestCase): ...@@ -43,13 +43,13 @@ class TestMessage(unittest.TestCase):
try: try:
response = push.send() response = push.send()
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
except common.Unauthorized, e: except common.Unauthorized as e:
self.assertFalse(isinstance(e, common.Unauthorized)) self.assertFalse(isinstance(e, common.Unauthorized))
raise common.Unauthorized("Unauthorized") raise common.Unauthorized("Unauthorized")
except common.APIConnectionException, e: except common.APIConnectionException as e:
self.assertFalse(isinstance(e, common.APIConnectionException)) self.assertFalse(isinstance(e, common.APIConnectionException))
raise common.APIConnectionException("conn") raise common.APIConnectionException("conn")
except common.JPushFailure, e: except common.JPushFailure as e:
self.assertFalse(isinstance(e, common.JPushFailure)) self.assertFalse(isinstance(e, common.JPushFailure))
print ("JPushFailure") print ("JPushFailure")
except: except:
......
...@@ -23,6 +23,6 @@ class TestEntity(unittest.TestCase): ...@@ -23,6 +23,6 @@ class TestEntity(unittest.TestCase):
try: try:
result = report.get_users("DAY","2016-04-10","3") result = report.get_users("DAY","2016-04-10","3")
self.assertEqual(result.status_code, 200) self.assertEqual(result.status_code, 200)
except common.JPushFailure, e: except common.JPushFailure as e:
self.assertIsInstance(e, common.JPushFailure) self.assertIsInstance(e, common.JPushFailure)
...@@ -37,7 +37,7 @@ class TestEntity(unittest.TestCase): ...@@ -37,7 +37,7 @@ class TestEntity(unittest.TestCase):
try: try:
result = schedule.get_schedule_by_id("3fc6e2fa-15a6-11e6-83d4-0021f653c222") result = schedule.get_schedule_by_id("3fc6e2fa-15a6-11e6-83d4-0021f653c222")
self.assertNotEqual(result.status_code, 200) self.assertNotEqual(result.status_code, 200)
except common.JPushFailure, e: except common.JPushFailure as e:
self.assertIsInstance(e, common.JPushFailure) self.assertIsInstance(e, common.JPushFailure)
def test_get_schedule_list(self): def test_get_schedule_list(self):
...@@ -69,6 +69,6 @@ class TestEntity(unittest.TestCase): ...@@ -69,6 +69,6 @@ class TestEntity(unittest.TestCase):
try: try:
result = schedule.delete_schedule("e9c553d0-0850-11e6-b6d4-0021f652c102") result = schedule.delete_schedule("e9c553d0-0850-11e6-b6d4-0021f652c102")
self.assertNotEqual(result.status_code, 200) self.assertNotEqual(result.status_code, 200)
except common.JPushFailure, e: except common.JPushFailure as e:
self.assertIsInstance(e, common.JPushFailure) self.assertIsInstance(e, common.JPushFailure)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment