Commit 21138a9e by Dan Robinson

removed CollectedItem during teardown

parent 3ee7b64f
...@@ -83,14 +83,18 @@ class TestObject(unittest.TestCase): ...@@ -83,14 +83,18 @@ class TestObject(unittest.TestCase):
def setUp(self): def setUp(self):
self.score = GameScore(score=1337, player_name='John Doe', cheat_mode=False) self.score = GameScore(score=1337, player_name='John Doe', cheat_mode=False)
self.sao_paulo = City(name='São Paulo', location=GeoPoint(-23.5, -46.6167)) self.sao_paulo = City(name='São Paulo', location=GeoPoint(-23.5, -46.6167))
self.collected_item = CollectedItem(type="Sword", isAwesome=True)
def tearDown(self): def tearDown(self):
city_name = getattr(self.sao_paulo, 'name', None) city_name = getattr(self.sao_paulo, 'name', None)
game_score = getattr(self.score, 'score', None) game_score = getattr(self.score, 'score', None)
collected_item_type = getattr(self.collected_item, 'type', None)
if city_name: if city_name:
ParseBatcher().batch_delete(City.Query.filter(name=city_name)) ParseBatcher().batch_delete(City.Query.filter(name=city_name))
if game_score: if game_score:
ParseBatcher().batch_delete(GameScore.Query.filter(score=game_score)) ParseBatcher().batch_delete(GameScore.Query.filter(score=game_score))
if collected_item_type:
ParseBatcher().batch_delete(CollectedItem.Query.filter(type=collected_item_type))
def testCanInitialize(self): def testCanInitialize(self):
self.assertEqual(self.score.score, 1337, 'Could not set score') self.assertEqual(self.score.score, 1337, 'Could not set score')
...@@ -142,10 +146,9 @@ class TestObject(unittest.TestCase): ...@@ -142,10 +146,9 @@ class TestObject(unittest.TestCase):
def testAssociatedObject(self): def testAssociatedObject(self):
"""test saving and associating a different object""" """test saving and associating a different object"""
collectedItem = CollectedItem(type="Sword", isAwesome=True)
collectedItem.save()
self.score.item = collectedItem self.collected_item.save()
self.score.item = self.collected_item
self.score.save() self.score.save()
# get the object, see if it has saved # get the object, see if it has saved
......
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