本文整理汇总了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))
示例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),
])
示例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)
示例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]')
示例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')
示例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)))
示例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"
示例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'])
示例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'})
示例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/')
示例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'})
示例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
示例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'})
示例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'})
示例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"