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.'}
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"))