Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jpush-api-python-client
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
jpush-api-python-client
Commits
b745fa26
Commit
b745fa26
authored
May 06, 2016
by
fendouai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add status_code ,add create device test
parent
25300fa5
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
37 additions
and
8 deletions
+37
-8
example_updevice.py
examples/device/example_updevice.py
+4
-1
common.py
jpush/common.py
+1
-2
core.py
jpush/core.py
+2
-0
core.py
jpush/device/core.py
+8
-2
entity.py
jpush/device/entity.py
+1
-1
core.py
jpush/push/core.py
+1
-0
conf.py
tests/devices/conf.py
+3
-0
test_devices.py
tests/devices/test_devices.py
+14
-2
test_entity.py
tests/devices/test_entity.py
+1
-0
test_audience.py
tests/push/test_audience.py
+1
-0
test_message.py
tests/push/test_message.py
+1
-0
No files found.
examples/device/example_updevice.py
View file @
b745fa26
...
...
@@ -5,4 +5,6 @@ _jpush = jpush.JPush(app_key, master_secret)
device
=
_jpush
.
create_device
()
reg_id
=
'1507bfd3f7c466c355c'
entity
=
jpush
.
device_tag
(
jpush
.
add
(
"ddd"
,
"tageee"
))
device
.
set_devicemobile
(
reg_id
,
entity
)
result
=
device
.
set_devicemobile
(
reg_id
,
entity
)
print
result
.
status_code
print
result
.
payload
\ No newline at end of file
jpush/common.py
View file @
b745fa26
...
...
@@ -66,8 +66,7 @@ class JPushFailure(Exception):
"Request failed with status
%
d: '
%
s
%
s':
%
s"
,
response
.
status_code
,
error_code
,
error
,
json
.
dumps
(
details
))
return
cls
(
error
,
error_code
,
details
,
response
,
response
.
status_code
,
response
.
content
)
return
cls
(
error
,
error_code
,
details
,
response
,
response
.
status_code
,
response
.
content
)
class
APIConnectionException
(
Exception
):
...
...
jpush/core.py
View file @
b745fa26
...
...
@@ -75,6 +75,8 @@ class JPush(object):
logging
.
basicConfig
(
level
=
logging
.
NOTSET
)
else
:
print
"set logging level failed ,the level is invalid."
else
:
print
"set logging level failed ,the level is invalid."
def
create_push
(
self
):
"""Create a Push notification."""
...
...
jpush/device/core.py
View file @
b745fa26
...
...
@@ -2,6 +2,7 @@
from
jpush
import
common
import
json
class
Device
(
object
):
"""Device info query/update..
...
...
@@ -14,8 +15,7 @@ class Device(object):
"""Send the request
"""
response
=
self
.
_jpush
.
_request
(
method
,
body
,
url
,
content_type
,
version
=
3
)
response
=
self
.
_jpush
.
_request
(
method
,
body
,
url
,
content_type
,
version
=
3
)
return
DeviceResponse
(
response
)
def
get_taglist
(
self
):
...
...
@@ -110,6 +110,7 @@ class Device(object):
print
(
info
)
return
info
class
DeviceResponse
(
object
):
"""Response to a successful device request send.
...
...
@@ -119,13 +120,18 @@ class DeviceResponse(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
"Device response Payload: {0}"
.
format
(
self
.
payload
)
jpush/device/entity.py
View file @
b745fa26
#!/usr/bin/env python
#-*- coding:utf8 -*-
#
-*- coding:utf8 -*-
import
sys
if
2
!=
sys
.
version_info
[
0
]:
...
...
jpush/push/core.py
View file @
b745fa26
...
...
@@ -5,6 +5,7 @@ from jpush import common
logger
=
logging
.
getLogger
(
'jpush'
)
class
Push
(
object
):
"""A push notification. Set audience, message, etc, and send."""
...
...
tests/devices/conf.py
0 → 100644
View file @
b745fa26
app_key
=
u'6be9204c30b9473e87bad4dc'
master_secret
=
u'9349ad7c90292a603c512e92'
\ No newline at end of file
tests/devices/test_devices.py
View file @
b745fa26
import
unittest
import
requests
import
jpush
from
jpush
import
device
import
jpush
as
jpush
from
conf
import
app_key
,
master_secret
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
device
=
_jpush
.
create_device
()
class
TestEntity
(
unittest
.
TestCase
):
def
test_create_device
(
self
):
reg_id
=
'1507bfd3f7c466c355c'
entity
=
jpush
.
device_tag
(
jpush
.
add
(
"ddd"
,
"tageee"
))
result
=
device
.
set_devicemobile
(
reg_id
,
entity
)
self
.
assertEqual
(
result
.
status_code
,
200
)
tests/devices/test_entity.py
View file @
b745fa26
import
unittest
import
jpush
class
TestEntity
(
unittest
.
TestCase
):
def
test_basic_entity
(
self
):
...
...
tests/push/test_audience.py
View file @
b745fa26
import
unittest
import
jpush
as
jpush
class
TestAudience
(
unittest
.
TestCase
):
def
test_basic_selectors
(
self
):
...
...
tests/push/test_message.py
View file @
b745fa26
...
...
@@ -2,6 +2,7 @@
import
unittest
import
jpush
as
jpush
class
TestMessage
(
unittest
.
TestCase
):
def
test_simple_alert
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment