def create_or_login(resp): match = _steam_id_re.search(resp.identity_url) g.user = User.get_or_create(match.group(1)) steamdata = get_steam_userinfo(g.user.steamid) g.user.nickname = steamdata['personaname'] db.session.commit() session['user_id'] = g.user.id return redirect(oid.get_next_url())
def test_create_account(self): steamid = "au9a0ou9ea0" # There should only be one user u = User.get_or_create(steamid) db.session.commit() user_count = User.query.count() self.assertEqual(user_count, 1) # There should only be one user u2 = User.get_or_create(steamid) db.session.commit() user_count2 = User.query.count() self.assertEqual(user_count2, 1) # Now there should be 2 users u3 = User.get_or_create("ah9oe0uh") db.session.commit() user_count3 = User.query.count() self.assertEqual(user_count3, 2)