Commit cdb18bd6 by David Robinson

Merge pull request #108 from danrobinson/fix_tests

Fixed minor problems caused by tests
parents 560ada66 28161926
...@@ -169,7 +169,10 @@ class ParseBatcher(ParseBase): ...@@ -169,7 +169,10 @@ class ParseBatcher(ParseBase):
# perform the callbacks with the response data (updating the existing # perform the callbacks with the response data (updating the existing
# objets, etc) # objets, etc)
for callback, response in zip(callbacks, responses): for callback, response in zip(callbacks, responses):
callback(response["success"]) if "success" in response:
callback(response["success"])
else:
raise core.ParseError(response["error"])
def batch_save(self, objects): def batch_save(self, objects):
"""save a list of objects in one operation""" """save a list of objects in one operation"""
......
...@@ -83,15 +83,19 @@ class TestObject(unittest.TestCase): ...@@ -83,15 +83,19 @@ 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
...@@ -392,6 +395,8 @@ class TestFunction(unittest.TestCase): ...@@ -392,6 +395,8 @@ class TestFunction(unittest.TestCase):
os.chdir(cloud_function_dir) os.chdir(cloud_function_dir)
if not os.path.exists("config"): if not os.path.exists("config"):
os.makedirs("config") os.makedirs("config")
if not os.path.exists("public"):
os.makedirs("public")
# write the config file # write the config file
with open("config/global.json", "w") as outf: with open("config/global.json", "w") as outf:
outf.write(GLOBAL_JSON_TEXT % (settings_local.APPLICATION_ID, outf.write(GLOBAL_JSON_TEXT % (settings_local.APPLICATION_ID,
......
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