def test_store_json(self): store = StoreModel('test') expected = {'name': 'test', 'items': []} self.assertEqual( store.json(), expected, "The JSON export of the store is incorrect. Received {}, expected {}." .format(store.json(), expected))
def post(self, name): if StoreModel.find_by_name(name): return { 'message': "A store with name '{}' already exists.".format(name) }, 400 store = StoreModel(name) try: store.save_to_db() except: return {"message": "An error occurred creating the store."}, 500 return store.json(), 201