def test_get_by_shortname_exists(self): result = Link.get_by_shortname('foo') self.assertEqual(result.__class__, Link)
def test_get_by_shortname_nonexistent(self): result = Link.get_by_shortname('this does not exist') self.assertEqual(result, None)
def show_shorturl(shorturl): link = Link.get_by_shortname(shorturl) if link is None: abort(404) link.get_hit(current_user).add_hit() return redirect(link.url)