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):
# perform the callbacks with the response data (updating the existing
# objets, etc)
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):
"""save a list of objects in one operation"""
......
......@@ -83,15 +83,19 @@ class TestObject(unittest.TestCase):
def setUp(self):
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.collected_item = CollectedItem(type="Sword", isAwesome=True)
def tearDown(self):
city_name = getattr(self.sao_paulo, 'name', None)
game_score = getattr(self.score, 'score', None)
collected_item_type = getattr(self.collected_item, 'type', None)
if city_name:
ParseBatcher().batch_delete(City.Query.filter(name=city_name))
if 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):
self.assertEqual(self.score.score, 1337, 'Could not set score')
......@@ -142,10 +146,9 @@ class TestObject(unittest.TestCase):
def testAssociatedObject(self):
"""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()
# get the object, see if it has saved
......@@ -392,6 +395,8 @@ class TestFunction(unittest.TestCase):
os.chdir(cloud_function_dir)
if not os.path.exists("config"):
os.makedirs("config")
if not os.path.exists("public"):
os.makedirs("public")
# write the config file
with open("config/global.json", "w") as outf:
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