本文整理汇总了Python中tracim_backend.lib.core.user.UserApi.save方法的典型用法代码示例。如果您正苦于以下问题:Python UserApi.save方法的具体用法?Python UserApi.save怎么用?Python UserApi.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracim_backend.lib.core.user.UserApi
的用法示例。
在下文中一共展示了UserApi.save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_api__try_whoami_enpoint__err_401__user_is_not_active
# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import save [as 别名]
def test_api__try_whoami_enpoint__err_401__user_is_not_active(self):
dbsession = get_tm_session(self.session_factory, transaction.manager)
admin = dbsession.query(User) \
.filter(User.email == '[email protected]') \
.one()
uapi = UserApi(
current_user=admin,
session=dbsession,
config=self.app_config,
)
gapi = GroupApi(
current_user=admin,
session=dbsession,
config=self.app_config,
)
groups = [gapi.get_one_with_name('users')]
test_user = uapi.create_user(
email='[email protected]',
password='password',
name='bob',
groups=groups,
timezone='Europe/Paris',
lang='en',
do_save=True,
do_notify=False,
)
uapi.save(test_user)
uapi.disable(test_user)
transaction.commit()
self.testapp.authorization = (
'Basic',
(
'[email protected]',
'password'
)
)
res = self.testapp.get('/api/v2/auth/whoami', status=401)
assert isinstance(res.json, dict)
assert 'code' in res.json.keys()
# INFO - G.M - 2018-09-10 - Handled by marshmallow_schema
assert res.json_body['code'] is None
assert 'message' in res.json.keys()
assert 'details' in res.json.keys()
示例2: test_api__try_login_enpoint__err_401__user_not_activated
# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import save [as 别名]
def test_api__try_login_enpoint__err_401__user_not_activated(self):
dbsession = get_tm_session(self.session_factory, transaction.manager)
admin = dbsession.query(User) \
.filter(User.email == '[email protected]') \
.one()
uapi = UserApi(
current_user=admin,
session=dbsession,
config=self.app_config,
)
gapi = GroupApi(
current_user=admin,
session=dbsession,
config=self.app_config,
)
groups = [gapi.get_one_with_name('users')]
test_user = uapi.create_user(
email='[email protected]',
password='password',
name='bob',
groups=groups,
timezone='Europe/Paris',
do_save=True,
do_notify=False,
)
uapi.save(test_user)
uapi.disable(test_user)
transaction.commit()
params = {
'email': '[email protected]',
'password': '[email protected]',
}
res = self.testapp.post_json(
'/api/v2/auth/login',
params=params,
status=403,
)
assert res.json_body
assert 'code' in res.json_body
assert res.json_body['code'] == error.AUTHENTICATION_FAILED