Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_get_schedule_by_invalid_id(self):
try:
result = report.get_users("DAY","2016-04-10","3")
self.assertEqual(result.status_code, 200)
except common.JPushFailure, e:
print e
self.assertIsInstance(e, common.JPushFailure)
def test_get_schedule_by_invalid_id(self):
try:
result = report.get_users("DAY","2016-04-10","3")
self.assertEqual(result.status_code, 200)
except common.JPushFailure, e:
print e
self.assertIsInstance(e, common.JPushFailure)
jpush.alias("alias1", "alias2")
)
push.notification = jpush.notification(alert="Hello world with audience!")
push.platform = jpush.all_
try:
response = push.send()
print response.status_code
self.assertEqual(response.status_code, 200)
except common.Unauthorized, e:
self.assertFalse(isinstance(e, common.Unauthorized))
raise common.Unauthorized("Unauthorized")
except common.APIConnectionException, e:
self.assertFalse(isinstance(e, common.APIConnectionException))
raise common.APIConnectionException("conn")
except common.JPushFailure, e:
self.assertFalse(isinstance(e, common.JPushFailure))
print "JPushFailure"
except:
self.assertFalse(1)
print "Exception"
def test_get_device(self):
reg_id = '090c1f59f89'
try:
device.get_deviceinfo(reg_id)
except common.JPushFailure:
self.assertEqual(1, 1)
except:
self.assertEqual(1, 0)
_jpush = jpush.JPush(app_key, master_secret)
push = _jpush.create_push()
push.audience = jpush.all_
push.notification = jpush.notification(alert="hello python jpush api")
push.platform = jpush.all_
try:
response = push.send()
print response.status_code
self.assertEqual(response.status_code, 200)
except common.Unauthorized, e:
self.assertFalse(isinstance(e, common.Unauthorized))
raise common.Unauthorized("Unauthorized")
except common.APIConnectionException, e:
self.assertFalse(isinstance(e, common.APIConnectionException))
raise common.APIConnectionException("conn")
except common.JPushFailure, e:
self.assertFalse(isinstance(e, common.JPushFailure))
print "JPushFailure"
except:
self.assertFalse(1)
print "Exception"
push = _jpush.create_push()
push.audience = jpush.all_
push.notification = jpush.notification(alert="hello python jpush api")
push.platform = jpush.all_
try:
response = push.send()
print response.status_code
self.assertEqual(response.status_code, 200)
except common.Unauthorized, e:
self.assertFalse(isinstance(e, common.Unauthorized))
raise common.Unauthorized("Unauthorized")
except common.APIConnectionException, e:
self.assertFalse(isinstance(e, common.APIConnectionException))
raise common.APIConnectionException("conn")
except common.JPushFailure, e:
self.assertFalse(isinstance(e, common.JPushFailure))
print "JPushFailure"
except:
self.assertFalse(1)
print "Exception"
jpush.tag("tag1", "tag2"),
jpush.alias("alias1", "alias2")
)
push.notification = jpush.notification(alert="Hello world with audience!")
push.platform = jpush.all_
try:
response = push.send()
print response.status_code
self.assertEqual(response.status_code, 200)
except common.Unauthorized, e:
self.assertFalse(isinstance(e, common.Unauthorized))
raise common.Unauthorized("Unauthorized")
except common.APIConnectionException, e:
self.assertFalse(isinstance(e, common.APIConnectionException))
raise common.APIConnectionException("conn")
except common.JPushFailure, e:
self.assertFalse(isinstance(e, common.JPushFailure))
print "JPushFailure"
except:
self.assertFalse(1)
print "Exception"
from .report import (
Report,
ReportResponse,
)
from .schedule import (
Schedule,
schedulepayload,
)
__all__ = [
JPush,
GroupPush,
Admin,
JPushFailure,
Unauthorized,
all_,
Push,
tag,
tag_and,
tag_not,
alias,
registration_id,
notification,
ios,
android,
winphone,
message,
smsmessage,
platform,
audience,
method, url, '\n\t'.join('%s: %s' % (key, value) for (key, value) in headers.items()), body)
try:
response = self.session.request(method, url, data=body, params=params,
headers=headers, timeout=self.timeout)
except requests.exceptions.ConnectTimeout:
raise common.APIConnectionException("Connection to api.jpush.cn timed out.")
except Exception:
raise common.APIRequestException("Connection to api.jpush.cn error.")
logger.debug("Received %s response. Headers:\n\t%s\nBody:\n\t%s", response.status_code, '\n\t'.join(
'%s: %s' % (key, value) for (key, value) in response.headers.items()), response.content)
if response.status_code == 401:
raise common.Unauthorized("Please check your AppKey and Master Secret")
elif not (200 <= response.status_code < 300):
raise common.JPushFailure.from_response(response)
return response