当前位置: 首页>>代码示例>>Python>>正文


Python UserApi.save方法代码示例

本文整理汇总了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()
开发者ID:tracim,项目名称:tracim,代码行数:46,代码来源:test_session.py

示例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
开发者ID:tracim,项目名称:tracim,代码行数:43,代码来源:test_session.py


注:本文中的tracim_backend.lib.core.user.UserApi.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。