Ejemplo n.º 1
0
	def test_log_visit(self):
		#due to the not so great nature of adding false entries to , 
		#I'm grouping a few tests here
		less = model.db.query(func.count(Visit.id)).first()
		original = model.url_info(self.code)
		model.log_visit(self.code)
		greater = model.db.query(func.count(Visit.id)).first()
		new = model.url_info(self.code)
		self.assertGreater(greater, less)
		self.assertEqual(original.url, new.url)
Ejemplo n.º 2
0
def redirect_on_code(code):
	try:
		model.db_connect()
		model.log_visit(code)
		url = model.url_info(code)
		model.db.close()
		return redirect(url.url)
	except:
		model.db.close()
		return render_template('404.html'), 404