def test_create_code(self): #due to the not so great nature of adding false entries to #the database, I'm grouping a few tests here model.db_connect() less = model.db.query(func.count(Url.code)).first() code = model.create_code(self.url) greater = model.db.query(func.count(Url.code)).first() self.assertGreater(greater, less) self.assertEqual(len(code), 6) model.db.query(Url).filter_by(code=code).delete() model.db.commit()
def new_code(): url = request.args.get("url") model.db_connect() code = model.create_code(url) model.db.close() return render_template("new_code.html", url=url, code=code)