def test_get_user_by_username(self): """ test the get_user_by_username controller """ self.create_new_user('foobar', '*****@*****.**', '12345678') fetched_user= get_user_by_username('foobar') self.assertEqual(fetched_user.email, '*****@*****.**')
def test_get_user_by_username(self): """ test the get_user_by_username controller """ self.create_new_user('foobar', '*****@*****.**', '12345678') fetched_user = get_user_by_username('foobar') self.assertEqual(fetched_user.email, '*****@*****.**')
def create_and_return_local_user(self, username='******', googleID = '123'): ''' create a user with a default email address and formal name, return that object a helper function for tests that require a local (app) user to operate ''' new_user(username = username, email='*****@*****.**', formalName ='James Smith', googleID = googleID) return get_user_by_username(username)
def test_edit_existing_user(self): ''' test that the edit user function is working as it should ''' this_username = '******' new_user(this_username, 'James Smith', '*****@*****.**', '12345678') edit_user(this_username, formalName='Nathan Smith') user = get_user_by_username(this_username) self.assertEqual(user.formalName, 'Nathan Smith')
def get(self, username): """ get request displays the teacher's profile page """ teacher = get_user_by_username(username) return render_template('profile.html', teacher=teacher, active_user=get_active_user(), google_users_api=users, mathjax=True)
def get(self, username): """ get request displays the teacher's profile page """ teacher = get_user_by_username(username) return render_template( 'profile.html', teacher = teacher, active_user = get_active_user(), google_users_api = users, mathjax = True )
def get(self, username): """ get request displays the teacher's sponsor page """ teacher = get_user_by_username(username) if sponsored(teacher): return render_template('already_sponsored.html', teacher=teacher) else: return render_template( 'sponsor.html', teacher=teacher, stripe_publish_key=pub_key, )
def test_edit_existing_user(self): ''' test that the edit user function is working as it should ''' this_username = '******' new_user(this_username, 'James Smith', '*****@*****.**', '12345678') edit_user(this_username, formalName ='Nathan Smith') user = get_user_by_username(this_username) self.assertEqual(user.formalName, 'Nathan Smith')
def get(self, username): """ get request displays the teacher's sponsor page """ teacher = get_user_by_username(username) if sponsored(teacher): return render_template( 'already_sponsored.html', teacher = teacher ) else: return render_template( 'sponsor.html', teacher = teacher, stripe_publish_key = pub_key, )
def post(self, username): """ handle the sponsor payment """ stripeToken = request.form['stripeToken'] teacher = get_user_by_username(username) try: new_sponsor(stripeToken, teacher) except Exception as e: return render_template( 'sponsor.html', teacher=teacher, stripe_publish_key=pub_key, error=True, error_msg=str(e), ) else: return render_template('sponsor_success.html', teacher=teacher)
def post(self, username): """ handle the sponsor payment """ stripeToken = request.form['stripeToken'] teacher = get_user_by_username(username) try: new_sponsor(stripeToken, teacher) except Exception as e: return render_template( 'sponsor.html', teacher = teacher, stripe_publish_key = pub_key, error = True, error_msg = str(e), ) else: return render_template( 'sponsor_success.html', teacher = teacher )