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
4e914882
Commit
4e914882
authored
Jul 10, 2017
by
Helperhaps
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix tests
parent
812a8b4b
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
55 deletions
+16
-55
.travis.yml
.travis.yml
+3
-1
conf.py
tests/devices/conf.py
+0
-3
conf.py
tests/push/conf.py
+0
-3
conf.py
tests/report/conf.py
+0
-3
conf.py
tests/schedule/conf.py
+0
-3
test_schedule.py
tests/schedule/test_schedule.py
+13
-42
No files found.
.travis.yml
View file @
4e914882
...
@@ -5,10 +5,12 @@ python:
...
@@ -5,10 +5,12 @@ python:
# - "3.2"
# - "3.2"
# - "3.3"
# - "3.3"
# - "3.4"
# - "3.4"
-
"
3.5"
-
"
3.6"
# command to install dependencies
# command to install dependencies
install
:
install
:
-
pip install .
-
pip install .
# command to run tests
# command to run tests
script
:
nosetests tests/
push tests/devices --verbosity=2
script
:
nosetests tests/
* --verbosity=2
tests/devices/conf.py
deleted
100644 → 0
View file @
812a8b4b
# please put your app_key and master_secret here
app_key
=
u'6be9204c30b9473e87bad4dc'
master_secret
=
u'cae22120eed6835e486399a7'
tests/push/conf.py
deleted
100644 → 0
View file @
812a8b4b
# please put your app_key and master_secret here
app_key
=
u'6be9204c30b9473e87bad4dc'
master_secret
=
u'cae22120eed6835e486399a7'
tests/report/conf.py
deleted
100644 → 0
View file @
812a8b4b
# please put your app_key and master_secret here
app_key
=
u'6be9204c30b9473e87bad4dc'
master_secret
=
u'cae22120eed6835e486399a7'
tests/schedule/conf.py
deleted
100644 → 0
View file @
812a8b4b
# please put your app_key and master_secret here
app_key
=
u'6be9204c30b9473e87bad4dc'
master_secret
=
u'cae22120eed6835e486399a7'
tests/schedule/test_schedule.py
View file @
4e914882
...
@@ -3,6 +3,7 @@ from jpush import schedule
...
@@ -3,6 +3,7 @@ from jpush import schedule
import
jpush
as
jpush
import
jpush
as
jpush
from
jpush
import
common
from
jpush
import
common
from
tests.conf
import
app_key
,
master_secret
from
tests.conf
import
app_key
,
master_secret
import
datetime
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
schedule
=
_jpush
.
create_schedule
()
schedule
=
_jpush
.
create_schedule
()
...
@@ -14,61 +15,31 @@ push.notification = jpush.notification(alert="Hello, world!")
...
@@ -14,61 +15,31 @@ push.notification = jpush.notification(alert="Hello, world!")
push
.
platform
=
jpush
.
all_
push
.
platform
=
jpush
.
all_
push
=
push
.
payload
push
=
push
.
payload
now
=
datetime
.
datetime
.
now
()
start_time
=
(
now
+
datetime
.
timedelta
(
days
=
10
))
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
end_time
=
(
now
+
datetime
.
timedelta
(
days
=
20
))
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
class
TestEntity
(
unittest
.
TestCase
):
class
TestEntity
(
unittest
.
TestCase
):
def
test_post_schedule
(
self
):
def
test_post_schedule
(
self
):
trigger
=
jpush
.
schedulepayload
.
trigger
(
"2016-07-17 12:00:00"
)
trigger
=
jpush
.
schedulepayload
.
trigger
(
start_time
)
schedulepayload
=
jpush
.
schedulepayload
.
schedulepayload
(
"name"
,
True
,
trigger
,
push
)
schedulepayload
=
jpush
.
schedulepayload
.
schedulepayload
(
"name"
,
True
,
trigger
,
push
)
result
=
schedule
.
post_schedule
(
schedulepayload
)
result
=
schedule
.
post_schedule
(
schedulepayload
)
self
.
assertEqual
(
result
.
status_code
,
200
)
self
.
assertEqual
(
result
.
status_code
,
200
)
def
test_post_schedule_periodical
(
self
):
trigger
=
jpush
.
schedulepayload
.
trigger
(
"12:00:00"
,
start
=
"2016-07-17 12:00:00"
,
end
=
"2016-09-17 12:00:00"
,
time_unit
=
"WEEK"
,
frequency
=
1
,
point
=
[
"WED"
,
"FRI"
])
schedulepayload
=
jpush
.
schedulepayload
.
schedulepayload
(
"periodical"
,
True
,
trigger
,
push
)
result
=
schedule
.
post_schedule
(
schedulepayload
)
self
.
assertEqual
(
result
.
status_code
,
200
)
def
test_get_schedule_by_id
(
self
):
def
test_get_schedule_by_id
(
self
):
result
=
schedule
.
get_schedule_by_id
(
"3fc6e2fa-15a6-11e6-83d4-0021f653c902"
)
schedule_id
=
schedule
.
get_schedule_list
(
"1"
)
.
payload
[
'schedules'
][
0
][
'schedule_id'
]
result
=
schedule
.
get_schedule_by_id
(
schedule_id
)
self
.
assertEqual
(
result
.
status_code
,
200
)
self
.
assertEqual
(
result
.
status_code
,
200
)
def
test_get_schedule_by_invalid_id
(
self
):
try
:
result
=
schedule
.
get_schedule_by_id
(
"3fc6e2fa-15a6-11e6-83d4-0021f653c222"
)
self
.
assertNotEqual
(
result
.
status_code
,
200
)
except
common
.
JPushFailure
as
e
:
self
.
assertIsInstance
(
e
,
common
.
JPushFailure
)
def
test_get_schedule_list
(
self
):
def
test_get_schedule_list
(
self
):
try
:
result
=
schedule
.
get_schedule_list
(
"1"
)
result
=
schedule
.
schedule
.
get_schedule_list
(
"1"
)
self
.
assertEqual
(
result
.
status_code
,
200
)
self
.
assertEqual
(
result
.
status_code
,
200
)
except
:
pass
def
test_put_invalid_schedule
(
self
):
trigger
=
jpush
.
schedulepayload
.
trigger
(
"2016-07-17 12:00:00"
)
schedulepayload
=
jpush
.
schedulepayload
.
schedulepayload
(
"update a new name"
,
True
,
trigger
,
push
)
try
:
result
=
schedule
.
put_schedule
(
schedulepayload
,
"3fc6e2fa-15a6-11e6-83d4-0021f653c902"
)
self
.
assertEqual
(
result
.
status_code
,
400
)
except
:
pass
def
test_put_schedule
(
self
):
def
test_put_schedule
(
self
):
trigger
=
jpush
.
schedulepayload
.
trigger
(
"2016-07-17 12:00:00"
)
task
=
schedule
.
get_schedule_list
(
"1"
)
.
payload
[
'schedules'
][
0
]
schedule_id
=
task
[
'schedule_id'
]
trigger
=
jpush
.
schedulepayload
.
trigger
(
task
[
'trigger'
][
'single'
][
'time'
])
schedulepayload
=
jpush
.
schedulepayload
.
schedulepayload
(
"update_a_new_name"
,
True
,
trigger
,
push
)
schedulepayload
=
jpush
.
schedulepayload
.
schedulepayload
(
"update_a_new_name"
,
True
,
trigger
,
push
)
try
:
result
=
schedule
.
put_schedule
(
schedulepayload
,
schedule_id
)
result
=
schedule
.
put_schedule
(
schedulepayload
,
"3fc6e2fa-15a6-11e6-83d4-0021f653c902"
)
self
.
assertEqual
(
result
.
status_code
,
200
)
self
.
assertEqual
(
result
.
status_code
,
200
)
except
:
pass
def
test_delete_schedule
(
self
):
try
:
result
=
schedule
.
delete_schedule
(
"e9c553d0-0850-11e6-b6d4-0021f652c102"
)
self
.
assertNotEqual
(
result
.
status_code
,
200
)
except
common
.
JPushFailure
as
e
:
self
.
assertIsInstance
(
e
,
jpush
.
common
.
JPushFailure
)
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