def create_bucketlist(name, created_by): bucketlist = BucketList.query.filter_by( name=name, created_by=created_by).first() if bucketlist: return jsonify({"message": "Bucketlist with the name %s already exist" % (name)}) else: bucketlist = BucketList(name, created_by) return jsonify({"message": "Saved", "name": name, "created_by": created_by }) if bucketlist.save() \ else jsonify({"message": "Cannot save bucketlist"})
def setUp(self): self.app = create_app("testing") self.app_context = self.app.app_context() self.app_context.push() db.drop_all() db.create_all() u = User(username=self.default_username) u.hash_password(self.default_password) u.save() g.user = u bucketlist = BucketList(name=self.default_bucketlist) bucketlist.create() bucketlist.save() item = BucketItem(name=self.default_bucketlistitem, bucketlist_id=bucketlist.id) item.create() item.save() self.client = self.app.test_client()
def setUp(self): """ Setup for Bucketlist API testing """ self.app = create_app('testing') self.client = self.app.test_client() db.create_all() # user creation user = User(username=self.username) user.hash_password(password=self.password) user.save() g.user = user # bucketlist creation bucketlist = BucketList(name=self.bucketlist_name) bucketlist.save() # bucketlistitem creation bucketlistitem = BucketListItem(name=self.bucketlistitem_name, bucketlist_id=bucketlist.id) bucketlistitem.save()