class UserManagerTestCase(unittest.TestCase): def setUp(self): self.user_manager = UserManager() self.user = User(id=123456789, first_name='chris', last_name='imberti', email='*****@*****.**', username='******', password='******', about='this is me', location='San Francisco, CA', website='https://stoksinterest.io/chris', image_url='http://chris', gender='male') def test_add_user(self): ret = self.user_manager.add_one(self.user) self.assertEquals(ret, 1) self.user['email'] = '*****@*****.**' ret = self.user_manager.update_one(self.user) self.assertEquals(ret, 1) self.user = self.user_manager.get_one(username='******') self.assertEquals(self.user.get('email'), '*****@*****.**') def test_delete_user(self): ret = self.user_manager.delete_one(self.user) self.assertEquals(ret, 1) def tearDown(self): pass
def signup(): if request.method == 'POST': username = request.form.get('username').encode('utf-8') first_name = request.form.get('firstname').encode('utf-8') last_name = request.form.get('lastname').encode('utf-8') email = request.form.get('email').encode('utf-8') password = request.form.get('password').encode('utf-8') user = User(username=username, first_name=first_name, last_name=last_name, email=email, password=password) user = base.managers.user_manager.add_one(user) # TODO: do this in a better way if user: login_handler.login_user(user.get('id'), user.get('username')) return render_template('profile.html') flash('Invalid login.', 'danger') return render_template('signup.html')