def test_model_get_by_username_fail(self, app): """Does our static method `User.get_by_username_or_404` correctly 404 given a non-existing username?""" with app.app_context(): try: User.get_by_username_or_404('asdf') except HTTPException as e: assert e.response is None assert e.description == "Resource not found."
def test_model_get_by_username(self, app): """Does our static method `User.get_by_username_or_404` retrieve an existing user given a correct username?""" with app.app_context(): user = User.query.first() testing_user = User.get_by_username_or_404('testing') assert testing_user == user
def view_user(username): """View a user's profile. This route may be viewed by an unauthorized user. TODO: Implement this. Currently being worked on by: Nick. """ user = User.get_by_username_or_404(username) return render_template('twitter/profile.html', user=user)