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
05c4ffd8
Commit
05c4ffd8
authored
Aug 21, 2015
by
Felipe Lavratti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added automatic conversion of array of pointers to parse object.
parent
15faf6bd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletions
+16
-1
parse_rest/datatypes.py
+3
-1
parse_rest/tests.py
+13
-0
No files found.
parse_rest/datatypes.py
View file @
05c4ffd8
...
@@ -35,6 +35,8 @@ class ParseType(object):
...
@@ -35,6 +35,8 @@ class ParseType(object):
@staticmethod
@staticmethod
def
convert_from_parse
(
parse_key
,
parse_data
):
def
convert_from_parse
(
parse_key
,
parse_data
):
if
isinstance
(
parse_data
,
list
):
return
[
ParseType
.
convert_from_parse
(
parse_key
,
item
)
for
item
in
parse_data
]
parse_type
=
None
parse_type
=
None
if
isinstance
(
parse_data
,
dict
):
if
isinstance
(
parse_data
,
dict
):
...
@@ -455,7 +457,7 @@ class Object(six.with_metaclass(ObjectMetaclass, ParseResource)):
...
@@ -455,7 +457,7 @@ class Object(six.with_metaclass(ObjectMetaclass, ParseResource)):
}
}
self
.
__class__
.
PUT
(
self
.
_absolute_url
,
**
payload
)
self
.
__class__
.
PUT
(
self
.
_absolute_url
,
**
payload
)
self
.
__dict__
[
key
]
+=
amount
self
.
__dict__
[
key
]
+=
amount
def
remove
(
self
,
key
):
def
remove
(
self
,
key
):
"""
"""
Clear a column value in the object. Note that this happens immediately:
Clear a column value in the object. Note that this happens immediately:
...
...
parse_rest/tests.py
View file @
05c4ffd8
...
@@ -359,6 +359,19 @@ class TestQuery(unittest.TestCase):
...
@@ -359,6 +359,19 @@ class TestQuery(unittest.TestCase):
self
.
assertTrue
(
score
.
game
.
objectId
)
self
.
assertTrue
(
score
.
game
.
objectId
)
#nice to have - also check no more then one query is triggered
#nice to have - also check no more then one query is triggered
def
testSelectRelatedArray
(
self
):
scores
=
GameScore
.
Query
.
all
()
game
=
Game
.
Query
.
all
()
.
limit
(
1
)[
0
]
game
.
score_array
=
scores
game
.
save
()
# Saved an array of pointers in the game
game
=
Game
.
Query
.
filter
(
objectId
=
game
.
objectId
)
.
select_related
(
'score_array'
)[
0
]
for
score
in
game
.
score_array
:
self
.
assertIsInstance
(
score
,
GameScore
)
self
.
assertEqual
(
score
.
player_name
,
'John Doe'
)
# This would trigger a GET if select_related were not used.
#nice to have - also check no more then one query is triggered
def
testCanCompareDateInequality
(
self
):
def
testCanCompareDateInequality
(
self
):
today
=
datetime
.
datetime
.
today
()
today
=
datetime
.
datetime
.
today
()
tomorrow
=
today
+
datetime
.
timedelta
(
days
=
1
)
tomorrow
=
today
+
datetime
.
timedelta
(
days
=
1
)
...
...
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