def test_setting_alias_fails_if_target_alias_exists(): user_id = db_utils.create_user() user_id_existing = db_utils.create_user() d.engine.execute("INSERT INTO useralias VALUES (%(id)s, %(alias)s, 'p')", id=user_id_existing, alias="existingalias") with pytest.raises(WeasylError) as err: useralias.set(user_id, "existingalias") assert 'usernameExists' == err.value.value
def manage_alias_post_(request): form = request.web_input(username="") useralias.set(request.userid, define.get_sysname(form.username)) raise HTTPSeeOther(location="/control")
def test_setting_alias_succeeds_when_previous_alias_exists(): config = CharSettings({'premium'}, {}, {}) user_id = db_utils.create_user(config=config) useralias.set(user_id, "previousalias") useralias.set(user_id, "alias") assert useralias.select(userid=user_id) == "alias"
def test_setting_alias_fails_if_user_does_not_have_premium_status(): user_id = db_utils.create_user() with pytest.raises(WeasylError) as err: useralias.set(user_id, "alias") assert 'InsufficientPermissions' == err.value.value
def test_setting_alias_fails_if_target_username_exists(): user_id = db_utils.create_user() db_utils.create_user(username="******") with pytest.raises(WeasylError) as err: useralias.set(user_id, "existinguser") assert 'usernameExists' == err.value.value
def POST(self): form = web.input(username="") useralias.set(self.user_id, define.get_sysname(form.username)) raise web.seeother("/control")