Commit fc8ac49d authored by fendouai's avatar fendouai

add status code to report api ,add report test

parent 46f63eb4
......@@ -11,7 +11,6 @@ class Report(object):
def __init__(self, jpush):
self._jpush = jpush
def send(self, method, url, body, content_type=None, version=3):
"""Send the request
......@@ -51,13 +50,18 @@ class ReportResponse(object):
"""
payload = None
status_code = None
def __init__(self, response):
self.status_code = response.status_code
if 0 != len(response.content):
data = response.json()
self.payload = data
elif 200 == response.status_code:
self.payload = "success"
def get_status_code(self):
return self.status_code
def __str__(self):
return "Report response Payload: {0}".format(self.payload)
\ No newline at end of file
#-*- coding:utf-8 -*-
# -*- coding:utf-8 -*-
import unittest
import jpush as jpush
......
import unittest
from jpush import schedule
import jpush as jpush
from conf import app_key, master_secret
from jpush import common
_jpush = jpush.JPush(app_key, master_secret)
schedule = _jpush.create_schedule()
_jpush.set_logging("DEBUG")
report=_jpush.create_report();
class TestEntity(unittest.TestCase):
def test_messages(self):
result = report.get_messages("3289406737")
self.assertEqual(result.status_code, 200)
def test_get_schedule_by_id(self):
result = report.get_received("3289406737")
self.assertEqual(result.status_code, 200)
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)
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