def mkusr(): u = User() u.id = 1 u.email = '*****@*****.**' u.username = '******' u.name = 'Kurohai' u.password = '******' u.admin = True session.add(u) session.commit()
def test_view_user_profile(self): from flaskapp import User, db, bcrypt, app from bs4 import BeautifulSoup # Add 2 users admin = User( username='******', email='*****@*****.**', password=bcrypt.generate_password_hash("admin").decode('utf-8')) susan = User( username='******', email='*****@*****.**', password=bcrypt.generate_password_hash("susan").decode('utf-8')) db.session.add(admin) db.session.add(susan) db.session.commit() # Try to view susan's profile without logging in test_client = app.test_client() response = test_client.get('/user/susan/profile', follow_redirects=True) response_soup = BeautifulSoup(response.data, 'html.parser') # Unsuccessful self.assertEqual(response_soup.title.string, u'Login - UMD Connect')
def test_create_user(self): from flaskapp import User, db, bcrypt # Add a user admin = User( username='******', email='*****@*****.**', password=bcrypt.generate_password_hash("admin").decode('utf-8')) db.session.add(admin) db.session.commit() # Check that the user was added. user = User.query.filter_by(username="******").first() self.assertEqual(user.username, "admin") self.assertEqual(user.email, "*****@*****.**")
def mkusr(): print 'adding user' u = User() a = Admin() u.username = a.username u.id = a.id u.email = a.email u.password = a.password u.admin = a.admin session.add(u) session.commit()