本文整理汇总了Python中models.profile.Profile.all方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.all方法的具体用法?Python Profile.all怎么用?Python Profile.all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.profile.Profile
的用法示例。
在下文中一共展示了Profile.all方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_signup_page_flow
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import all [as 别名]
def test_signup_page_flow(self):
# Check that things are empty
self.assertLength(0, Profile.all())
# Sign up with the form
response = self.app.post(self.uri_for('signup'), self.SIGNUP_DATA)
self.assertRedirects(response, self.uri_for('dashboard', tour=''))
# Check that we are actually logged in
response = self.app.get(response.location)
self.assertLoggedIn()
# Check that one of everything was created
self.assertLength(1, Profile.all())
profile = Profile.all().get()
# Check the basic data
self.assertEqual(self.SIGNUP_DATA['email'], profile.email)
self.assertEqual(self.SIGNUP_DATA['name'], profile.name)
# Logout and log back in to test that the password works
self.logout()
response = self.login(self.SIGNUP_DATA['email'],
self.SIGNUP_DATA['password'])
self.assertRedirects(response, self.uri_for('dashboard'))
示例2: test_signup_with_existing_email
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import all [as 别名]
def test_signup_with_existing_email(self):
response = self.app.post(self.uri_for('signup'), self.SIGNUP_DATA)
self.assertRedirects(response)
self.assertLength(1, Profile.all())
response = self.app.post(self.uri_for('signup'), self.SIGNUP_DATA)
self.assertOk(response)
self.assertLength(1, Profile.all())
email_field = response.pyquery('input#email')
self.assertLength(1, email_field)
self.assertNotEqual('', email_field.attr['data-error'])
示例3: test_signup_sends_welcome_email
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import all [as 别名]
def test_signup_sends_welcome_email(self):
# Sign up successfully
response = self.app.post(self.uri_for('signup'), self.SIGNUP_DATA)
self.assertRedirects(response, self.uri_for('dashboard', tour=''))
# Check that a profile was created
profile = Profile.get_by_email(self.SIGNUP_DATA['email'])
self.assertIsNotNone(profile)
# Check that a mail-sending task is in the queue
tasks = self.taskqueue_stub.GetTasks('mail')
self.assertLength(1, tasks)
# Run the task (it should be a deferred call) and check that an e-mail
# is sent
task, = tasks
deferred.run(base64.b64decode(task['body']))
messages = self.mail_stub.get_sent_messages()
self.assertLength(1, messages)
message, = messages
self.assertEqual('"%s" <%s>' % (profile.name, profile.email), message.to)
self.assertEqual('Welcome to Daily Meeting!', message.subject)
self.assertEqual('"Daily Meeting" <[email protected]>',
message.sender)
self.assertEqual('"Daily Meeting Support" <[email protected]>',
message.reply_to)
activation_key = Profile.all().get().activation_key
activation_url = self.uri_for('profile.activate', k=activation_key)
self.assertIn(activation_url, message.body.decode())
self.assertIn(activation_url, message.html.decode())
示例4: get
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import all [as 别名]
def get(self):
path = os.path.join(os.path.dirname(__file__),
'../views/admin/index.html')
template_values = {
'name': self.__class__.__name__,
'profiles': Profile.all(),
}
self.response.out.write(template.render(path, template_values))
示例5: get_profiles
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import all [as 别名]
def get_profiles(self):
return Profile.all().ancestor(self)
示例6: list
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import all [as 别名]
def list(self):
editors = Profile.all().filter('is_editor = ', True)
return self.render_to_response('editors/list.haml', {'editors': editors})