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


Python Client.flush方法代码示例

本文整理汇总了Python中radlibs.Client.flush方法的典型用法代码示例。如果您正苦于以下问题:Python Client.flush方法的具体用法?Python Client.flush怎么用?Python Client.flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在radlibs.Client的用法示例。


在下文中一共展示了Client.flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_invite_new_user_to_association

# 需要导入模块: from radlibs import Client [as 别名]
# 或者: from radlibs.Client import flush [as 别名]
    def test_invite_new_user_to_association(self, user, send_invitation_mail):
        user.email = "[email protected]"
        session = Client().session()

        association = Association(name='prancing ponies')
        session.add(association)
        session.flush()
        session.add(UserAssociation(user_id=user.user_id,
                                    association_id=association.association_id))
        session.flush()

        response = self.app.post(
            '/association/{0}/invite_user'.format(association.association_id),
            data={'email': '[email protected]'})
        eq_(response.status_code, 200, response.data)
        body = json.loads(response.data)
        eq_(body, {'status': 'ok', 'action': 'invited'})

        invite = session.query(AssociationInvite).one()
        eq_(invite.email, '[email protected]')
        eq_(invite.association_id, association.association_id)

        send_invitation_mail.assert_called_once_with(
            '[email protected]',
            '[email protected]',
            'prancing ponies',
            'http://localhost/accept_invitation/{0}/'.format(invite.token))
开发者ID:ErinCall,项目名称:radlibs,代码行数:29,代码来源:test_association.py

示例2: test_add_existing_user_to_association

# 需要导入模块: from radlibs import Client [as 别名]
# 或者: from radlibs.Client import flush [as 别名]
    def test_add_existing_user_to_association(self, user):
        session = Client().session()

        association = Association(name='prancing ponies')
        session.add(association)
        session.flush()
        session.add(UserAssociation(user_id=user.user_id,
                                    association_id=association.association_id))
        other_user = User(email_verified_at=utcnow(), email='[email protected]')
        session.add(other_user)
        session.flush()

        response = self.app.post(
            '/association/{0}/invite_user'.format(association.association_id),
            data={'email': '[email protected]'})
        eq_(response.status_code, 200, response.data)
        body = json.loads(response.data)
        eq_(body, {'status': 'ok', 'action': 'added'})

        user_associations = session.query(
            UserAssociation.user_id, UserAssociation.association_id).\
            all()
        eq_(user_associations, [
            (user.user_id, association.association_id),
            (other_user.user_id, association.association_id),
            ])
开发者ID:ErinCall,项目名称:radlibs,代码行数:28,代码来源:test_association.py

示例3: test_generate_token

# 需要导入模块: from radlibs import Client [as 别名]
# 或者: from radlibs.Client import flush [as 别名]
    def test_generate_token(self):
        session = Client().session()
        user = User()
        session.add(user)
        session.flush()

        token = EmailVerificationToken.generate(user)
        eq_(len(token.token), 32)
开发者ID:ErinCall,项目名称:radlibs,代码行数:10,代码来源:user.py

示例4: test_generate

# 需要导入模块: from radlibs import Client [as 别名]
# 或者: from radlibs.Client import flush [as 别名]
    def test_generate(self):
        session = Client().session()
        association = Association(name='crazy train')
        session.add(association)
        session.flush()

        invite = AssociationInvite.generate(association.association_id,
                                            '[email protected]')
开发者ID:ErinCall,项目名称:radlibs,代码行数:10,代码来源:test_association.py

示例5: test_no_such_lib_raises_keyerror

# 需要导入模块: from radlibs import Client [as 别名]
# 或者: from radlibs.Client import flush [as 别名]
    def test_no_such_lib_raises_keyerror(self, g):
        session = Client().session()
        association = Association(name="prancing ponies")
        session.add(association)
        session.flush()
        g.association_id = association.association_id

        radlibs.lib.load_lib('Loot')
开发者ID:ErinCall,项目名称:radlibs,代码行数:10,代码来源:test_load_lib.py

示例6: test_breadcrumb_for_an_association

# 需要导入模块: from radlibs import Client [as 别名]
# 或者: from radlibs.Client import flush [as 别名]
 def test_breadcrumb_for_an_association(self):
     session = Client().session()
     association = Association(name="Harpy")
     session.add(association)
     session.flush()
     with app.app_context():
         crumb = breadcrumb_for(association)
     eq_(crumb, ('Harpy', 'http://localhost/association/{0}'.format(
         association.association_id)))
开发者ID:ErinCall,项目名称:radlibs,代码行数:11,代码来源:test_breadcrumbs.py

示例7: test_accept_invite_prompts_for_login

# 需要导入模块: from radlibs import Client [as 别名]
# 或者: from radlibs.Client import flush [as 别名]
 def test_accept_invite_prompts_for_login(self):
     session = Client().session()
     association = Association(name="tower of power")
     session.add(association)
     session.flush()
     invite = AssociationInvite.generate(association.association_id,
                                         '[email protected]')
     session.flush()
     response = self.app.get('/accept_invitation/{0}/'.format(invite.token))
     eq_(response.status_code, 200)
     assert 'Please create an account' in response.data,\
         "Response didn't prompt for login"
开发者ID:ErinCall,项目名称:radlibs,代码行数:14,代码来源:test_association.py

示例8: register

# 需要导入模块: from radlibs import Client [as 别名]
# 或者: from radlibs.Client import flush [as 别名]
def register():
    db_session = Client().session()
    user = User(
        email=request.form['email'],
        identifier=session['partial_user']['identifier'])
    db_session.add(user)
    db_session.flush()
    token = EmailVerificationToken.generate(user)
    send_verification_mail(
        user, url_for('verify_email', token=token.token, _external=True))
    session['user'] = {'email': user.email, 'identifier': user.identifier}
    return redirect(request.form['redirect_uri'])
开发者ID:ErinCall,项目名称:radlibs,代码行数:14,代码来源:login.py

示例9: test_hmac_auth__invalid_datetime_format

# 需要导入模块: from radlibs import Client [as 别名]
# 或者: from radlibs.Client import flush [as 别名]
 def test_hmac_auth__invalid_datetime_format(self):
     session = Client().session()
     user = User(api_key='hurfdurf')
     session.add(user)
     session.flush()
     response = self.app.post(
         '/test_authorization', data={'user_id': user.user_id,
                                      'signature': 'johnhancock',
                                      'time': 'beer:30',
                                      'other_param': 'frabjous'})
     eq_(response.status_code, 200, response.data)
     body = json.loads(response.data)
     eq_(body, {'status': 'error', 'error': 'not logged in'})
开发者ID:ErinCall,项目名称:radlibs,代码行数:15,代码来源:test_login.py

示例10: test_bypass_login__existing_user

# 需要导入模块: from radlibs import Client [as 别名]
# 或者: from radlibs.Client import flush [as 别名]
    def test_bypass_login__existing_user(self):
        session = Client().session()
        user = User(identifier='http://www.facebook.com/itsme',
                    email='[email protected]')
        session.add(user)
        session.flush()

        response = self.app.post('/login_bypass', data={
            'email': '[email protected]',
            'identifier': 'http://www.facebook.com/itsme',
        })
        eq_(response.status_code, 302)
        eq_(response.headers['Location'], 'http://localhost/')
开发者ID:ErinCall,项目名称:radlibs,代码行数:15,代码来源:test_login.py

示例11: test_test_radlib_requires_login

# 需要导入模块: from radlibs import Client [as 别名]
# 或者: from radlibs.Client import flush [as 别名]
 def test_test_radlib_requires_login(self):
     session = Client().session()
     association = Association(name="somebody's private stuff")
     session.add(association)
     session.flush()
     response = self.app.post(
         '/association/{0}/test_radlib'.format(association.association_id),
         data={'rad': 'I ate some <Food>'})
     eq_(response.status_code, 200)
     body = json.loads(response.data)
     eq_(body, {
         'status': 'error',
         'error': 'login required'})
开发者ID:ErinCall,项目名称:radlibs,代码行数:15,代码来源:test_association.py

示例12: create_association

# 需要导入模块: from radlibs import Client [as 别名]
# 或者: from radlibs.Client import flush [as 别名]
    def create_association(self, user):
        session = Client().session()
        association = Association(name="Partytown")
        session.add(user)
        session.add(association)
        session.flush()

        user_association = UserAssociation(
            user_id=user.user_id,
            association_id=association.association_id)
        session.add(user_association)
        session.flush()

        return association.association_id
开发者ID:ErinCall,项目名称:radlibs,代码行数:16,代码来源:test_radlib.py

示例13: test_add_new_rad__requires_correct_user

# 需要导入模块: from radlibs import Client [as 别名]
# 或者: from radlibs.Client import flush [as 别名]
    def test_add_new_rad__requires_correct_user(self, user):
        session = Client().session()
        other_user = User()
        association_id = self.create_association(other_user)
        lib = Lib(name="Song", association_id=association_id)
        session.add(lib)
        session.flush()

        response = self.app.post('/lib/{0}/rad/new'.format(lib.lib_id),
                                 data={'rad': '<Song_which_never_ends>'})
        eq_(response.status_code, 200)
        body = json.loads(response.data)
        eq_(body, {
            'status': 'error',
            'error': 'no such lib'})
开发者ID:ErinCall,项目名称:radlibs,代码行数:17,代码来源:test_radlib.py

示例14: test_hmac_auth__user_has_no_api_key

# 需要导入模块: from radlibs import Client [as 别名]
# 或者: from radlibs.Client import flush [as 别名]
 def test_hmac_auth__user_has_no_api_key(self):
     session = Client().session()
     user = User()
     session.add(user)
     session.flush()
     time = datetime.datetime.utcnow().strftime('%Y%m%dT%H:%M:%S')
     signature = "mloop droop"
     response = self.app.post(
         '/test_authorization', data={'user_id': user.user_id,
                                      'signature': signature,
                                      'time': time,
                                      'other_param': 'frabjous'})
     eq_(response.status_code, 200, response.data)
     body = json.loads(response.data)
     eq_(body, {'status': 'error', 'error': 'not logged in'})
开发者ID:ErinCall,项目名称:radlibs,代码行数:17,代码来源:test_login.py

示例15: test_accept_invite_while_unverified_verifies_email

# 需要导入模块: from radlibs import Client [as 别名]
# 或者: from radlibs.Client import flush [as 别名]
 def test_accept_invite_while_unverified_verifies_email(self, user):
     user.email = '[email protected]'
     user.email_verified_at = None
     session = Client().session()
     association = Association(name="tower of power")
     session.add(association)
     session.flush()
     invite = AssociationInvite.generate(association.association_id,
                                         '[email protected]')
     session.flush()
     response = self.app.get('/accept_invitation/{0}/'.format(invite.token))
     eq_(response.status_code, 302, response.data)
     del(user)
     user = session.query(User).one()
     assert user.email_verified_at, "Email wasn't verified"
开发者ID:ErinCall,项目名称:radlibs,代码行数:17,代码来源:test_association.py


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