Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
ParsePy
Overview
Overview
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
OpenEdx
ParsePy
Commits
65bd3163
Commit
65bd3163
authored
Apr 09, 2014
by
dgrtwo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #34: adds batch saving for User objects + test case
parent
284b2078
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
3 deletions
+29
-3
parse_rest/tests.py
+16
-0
parse_rest/user.py
+12
-2
setup.py
+1
-1
No files found.
parse_rest/tests.py
View file @
65bd3163
...
@@ -425,6 +425,22 @@ class TestUser(unittest.TestCase):
...
@@ -425,6 +425,22 @@ class TestUser(unittest.TestCase):
self
.
assert_
(
User
.
Query
.
filter
(
phone
=
phone_number
)
.
exists
(),
self
.
assert_
(
User
.
Query
.
filter
(
phone
=
phone_number
)
.
exists
(),
'Failed to update user data. New info not on Parse'
)
'Failed to update user data. New info not on Parse'
)
def
testCanBatchUpdate
(
self
):
user
=
self
.
_get_logged_user
()
phone_number
=
"555-0134"
original_updatedAt
=
user
.
updatedAt
user
.
phone
=
phone_number
batcher
=
ParseBatcher
()
batcher
.
batch_save
([
user
])
self
.
assert_
(
User
.
Query
.
filter
(
phone
=
phone_number
)
.
exists
(),
'Failed to batch update user data. New info not on Parse'
)
self
.
assert_
(
user
.
updatedAt
!=
original_updatedAt
,
'Failed to batch update user data: updatedAt not changed'
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
# command line
# command line
...
...
parse_rest/user.py
View file @
65bd3163
...
@@ -55,11 +55,21 @@ class User(ParseResource):
...
@@ -55,11 +55,21 @@ class User(ParseResource):
return
{
'X-Parse-Session-Token'
:
self
.
sessionToken
}
return
{
'X-Parse-Session-Token'
:
self
.
sessionToken
}
@login_required
@login_required
def
save
(
self
):
def
save
(
self
,
batch
=
False
):
session_header
=
{
'X-Parse-Session-Token'
:
self
.
sessionToken
}
session_header
=
{
'X-Parse-Session-Token'
:
self
.
sessionToken
}
url
=
self
.
_absolute_url
url
=
self
.
_absolute_url
data
=
self
.
_to_native
()
data
=
self
.
_to_native
()
return
self
.
__class__
.
PUT
(
url
,
extra_headers
=
session_header
,
**
data
)
response
=
self
.
__class__
.
PUT
(
url
,
extra_headers
=
session_header
,
batch
=
batch
,
**
data
)
def
call_back
(
response_dict
):
self
.
updatedAt
=
response_dict
[
'updatedAt'
]
if
batch
:
return
response
,
call_back
else
:
call_back
(
response
)
@login_required
@login_required
def
delete
(
self
):
def
delete
(
self
):
...
...
setup.py
View file @
65bd3163
...
@@ -21,7 +21,7 @@ class TestCommand(Command):
...
@@ -21,7 +21,7 @@ class TestCommand(Command):
setup
(
setup
(
name
=
'parse_rest'
,
name
=
'parse_rest'
,
version
=
'0.2.201
31001
'
,
version
=
'0.2.201
41002
'
,
description
=
'A client library for Parse.com
\'
.s REST API'
,
description
=
'A client library for Parse.com
\'
.s REST API'
,
url
=
'https://github.com/dgrtwo/ParsePy'
,
url
=
'https://github.com/dgrtwo/ParsePy'
,
packages
=
[
'parse_rest'
],
packages
=
[
'parse_rest'
],
...
...
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