Commit 7ec07d1f by Dave Gadling

Add tests for Relation queries

Making an Object, and then marking that it's got Relation's doesn't
work. These tests demonstrate that. Next commit will fix whatever's
needed so that these tests pass.
parent 9b67ee0c
...@@ -59,6 +59,14 @@ class GameScore(Object): ...@@ -59,6 +59,14 @@ class GameScore(Object):
pass pass
class GameMap(Object):
pass
class GameMode(Object):
pass
class City(Object): class City(Object):
pass pass
...@@ -348,6 +356,25 @@ class TestQuery(unittest.TestCase): ...@@ -348,6 +356,25 @@ class TestQuery(unittest.TestCase):
self.assertEqual(GameScore.Query.filter(createdAt__lte=tomorrow).count(), 5, self.assertEqual(GameScore.Query.filter(createdAt__lte=tomorrow).count(), 5,
'Could not make inequality comparison with dates') 'Could not make inequality comparison with dates')
def testRelations(self):
"""Make some maps, make a Game Mode that has many maps, find all maps
given a Game Mode"""
maps = [GameMap(name="map " + i) for i in ['a', 'b', 'c', 'd']]
ParseBatcher().batch_save(maps)
gm = GameMode(name='test mode')
gm.save()
gm.addRelation("maps", GameMap.__name__, [m.objectId for m in maps])
modes = GameMode.Query.all()
self.assertEqual(len(modes), 1)
mode = modes[0]
maps_for_mode = GameMap.Query.filter(maps__relatedTo=mode)
self.assertEqual(len(maps_for_mode), 4)
gm.delete()
ParseBatcher().batch_delete(maps)
class TestFunction(unittest.TestCase): class TestFunction(unittest.TestCase):
def setUp(self): def setUp(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment