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
8a860036
Commit
8a860036
authored
Aug 22, 2014
by
hupantingxue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. Fix python 3 version issues;
2. Modify message test case;
parent
f0a70670
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
payload.py
jpush/push/payload.py
+4
-4
test_message.py
tests/push/test_message.py
+2
-1
No files found.
jpush/push/payload.py
View file @
8a860036
...
@@ -45,13 +45,13 @@ def ios(alert=None, badge=None, sound=None, content_available=False,
...
@@ -45,13 +45,13 @@ def ios(alert=None, badge=None, sound=None, content_available=False,
"""
"""
payload
=
{}
payload
=
{}
if
alert
is
not
None
:
if
alert
is
not
None
:
if
not
isinstance
(
alert
,
basestring
)
or
isinstance
(
alert
,
dict
):
if
not
isinstance
(
alert
,
str
)
or
isinstance
(
alert
,
dict
):
raise
ValueError
(
"iOS alert must be a string or dictionary"
)
raise
ValueError
(
"iOS alert must be a string or dictionary"
)
payload
[
'alert'
]
=
alert
payload
[
'alert'
]
=
alert
if
badge
is
not
None
:
if
badge
is
not
None
:
if
not
(
isinstance
(
badge
,
basestring
)
or
isinstance
(
badge
,
int
)):
if
not
(
isinstance
(
badge
,
str
)
or
isinstance
(
badge
,
int
)):
raise
ValueError
(
"iOS badge must be an integer or string"
)
raise
ValueError
(
"iOS badge must be an integer or string"
)
if
isinstance
(
badge
,
basestring
)
and
not
VALID_AUTOBADGE
.
match
(
badge
):
if
isinstance
(
badge
,
str
)
and
not
VALID_AUTOBADGE
.
match
(
badge
):
raise
ValueError
(
"Invalid iOS autobadge value"
)
raise
ValueError
(
"Invalid iOS autobadge value"
)
payload
[
'badge'
]
=
badge
payload
[
'badge'
]
=
badge
if
sound
is
not
None
:
if
sound
is
not
None
:
...
@@ -94,7 +94,7 @@ def winphone(alert, title=None, _open_page=None, extras=None):
...
@@ -94,7 +94,7 @@ def winphone(alert, title=None, _open_page=None, extras=None):
Must include exactly one of ``alert``, ``title``, ``_open_page``, or ``extras``.
Must include exactly one of ``alert``, ``title``, ``_open_page``, or ``extras``.
"""
"""
if
len
(
filter
(
None
,
(
alert
,
_open_page
,
title
)))
!=
1
:
if
len
(
list
(
filter
(
None
,
(
alert
,
_open_page
,
title
)
)))
!=
1
:
raise
ValueError
(
"MPNS payload must have one notification type."
)
raise
ValueError
(
"MPNS payload must have one notification type."
)
payload
=
{}
payload
=
{}
if
alert
is
not
None
:
if
alert
is
not
None
:
...
...
tests/push/test_message.py
View file @
8a860036
#-*- coding:utf-8 -*-
import
unittest
import
unittest
import
jpush
as
jpush
import
jpush
as
jpush
class
TestMessage
(
unittest
.
TestCase
):
class
TestMessage
(
unittest
.
TestCase
):
def
test_simple_alert
(
self
):
def
test_simple_alert
(
self
):
self
.
assertEqual
(
jpush
.
notification
(
alert
=
'
Hello'
),
{
'alert'
:
'Hello
'
})
self
.
assertEqual
(
jpush
.
notification
(
alert
=
'
中文'
),
{
'alert'
:
'中文
'
})
def
test_ios
(
self
):
def
test_ios
(
self
):
self
.
assertEqual
(
self
.
assertEqual
(
...
...
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