コード例 #1
0
ファイル: store.py プロジェクト: lekanakin/restApis
 def delete(self, name):
     store = StoreModel(name)
     if store:
         try:
             store.delete_from_db()
         except:
             return {
                 'message': '{} does not exist on the database'.format(name)
             }
     return {'message': 'Store Deleted.'}
コード例 #2
0
    def test_crud(self):

        with self.app_context():
            store = StoreModel("Costco")
            self.assertIsNotNone(store.name)
            self.assertIsNone(StoreModel.find_by_name("Costco"))

            store.save_to_db()

            self.assertIsNotNone(StoreModel.find_by_name("Costco"))

            store.delete_from_db()
            self.assertIsNone(StoreModel.find_by_name("Costco"))