Permalink
Browse files

Relational queries weren't possible because as_pointer was False from…

… the Queryset, fixed and added test for relational query. Updated PyPI version.
  • Loading branch information...
David Robinson
David Robinson committed Oct 1, 2013
1 parent 220a34f commit 8a0300d1f50b6976cc9a1f298f119fad33c728dc
Showing with 20 additions and 6 deletions.
  1. +1 −1 parse_rest/query.py
  2. +18 −4 parse_rest/tests.py
  3. +1 −1 setup.py
View
@@ -83,7 +83,7 @@ class Queryset(object):
@staticmethod
def convert_to_parse(value):
from datatypes import ParseType
- return ParseType.convert_to_parse(value)
+ return ParseType.convert_to_parse(value, as_pointer=True)
@classmethod
def extract_filter_operator(cls, parameter):
View
@@ -53,6 +53,10 @@
"""
+class Game(Object):
+ pass
+
+
class GameScore(Object):
pass
@@ -215,10 +219,15 @@ def setUp(self):
# first delete any that exist
for s in GameScore.Query.all():
s.delete()
+ for g in Game.Query.all():
+ g.delete()
+
+ self.game = Game(title="Candyland")
+ self.game.save()
self.scores = [
- GameScore(score=s, player_name='John Doe') for s in range(1, 6)
- ]
+ GameScore(score=s, player_name='John Doe', game=self.game)
+ for s in range(1, 6)]
for s in self.scores:
s.save()
@@ -239,14 +248,18 @@ def testCanFilter(self):
self.assert_(qobj.score == s.score,
"Getting object with .filter() failed")
+ # test relational query with other Objects
+ num_scores = GameScore.Query.filter(game=self.game).count()
+ self.assert_(num_scores == len(self.scores),
+ "Relational query with .filter() failed")
+
def testGetExceptions(self):
'''test possible exceptions raised by Queryset.get() method'''
self.assertRaises(query.QueryResourceDoesNotExist,
GameScore.Query.filter(score__gt=20).get)
self.assertRaises(query.QueryResourceMultipleResultsReturned,
GameScore.Query.filter(score__gt=3).get)
-
def testCanQueryDates(self):
last_week = datetime.datetime.now() - datetime.timedelta(days=7)
score = GameScore(name='test', last_played=last_week)
@@ -306,9 +319,10 @@ def testCanCompareDateInequality(self):
'Could not make inequality comparison with dates')
def tearDown(self):
- '''delete all GameScore objects'''
+ '''delete all GameScore and Game objects'''
for s in GameScore.Query.all():
s.delete()
+ self.game.delete()
class TestFunction(unittest.TestCase):
View
@@ -21,7 +21,7 @@ def run(self):
setup(
name='parse_rest',
- version='0.2.20130312',
+ version='0.2.20131001',
description='A client library for Parse.com\'.s REST API',
url='https://github.com/dgrtwo/ParsePy',
packages=['parse_rest'],

1 comment on commit 8a0300d

I think this fix caused this issue:
dgrtwo#28

Please sign in to comment.