本文整理汇总了Python中users.tests.profile函数的典型用法代码示例。如果您正苦于以下问题:Python profile函数的具体用法?Python profile怎么用?Python profile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了profile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_for_user_active
def test_for_user_active(self, get_current):
"""Checks the locale dashboard loads for a user associated with it."""
get_current.return_value.domain = 'testserver'
# Create user/group and add user to group.
u = user(username='test', save=True)
u.groups.add(self.g)
profile(u).save()
# Create site-wide and group announcements and dashboard.
announcement().save()
content = 'stardate 12341'
announcement(group=self.g, content=content).save()
# Log in and check response.
self.client.login(username='test', password='testpass')
response = self.client.get(reverse('dashboards.group',
args=[self.g.pk]), follow=True)
eq_(200, response.status_code)
doc = pq(response.content)
# The locale dash tab shows up.
eq_(4, len(doc('#doc-tabs li')))
# The locale dash tabs shows up and is active
eq_(u'A group', doc('#doc-tabs li.active').text())
# The subtitle shows French.
eq_(u'Deutsch', doc('#main h2.subtitle').text())
# The correct announcement shows up.
self.assertContains(response, content)
示例2: setUp
def setUp(self):
super(PasswordChangeTests, self).setUp()
self.u = user(save=True)
profile(user=self.u)
self.url = reverse('users.pw_change')
self.new_pw = 'fjdka387fvstrongpassword!'
self.client.login(username=self.u.username, password='testpass')
示例3: setUp
def setUp(self):
super(AnnouncementModelTests, self).setUp()
self.creator = user(save=True)
profile(user=self.creator)
self.group = group(save=True)
self.locale = locale(locale='es', save=True)
self.creator.groups.add(self.group)
示例4: test_for_user_active
def test_for_user_active(self, get_current):
"""Checks the locale dashboard loads for a user associated with it.
"""
get_current.return_value.domain = "testserver"
# Create user/group and add user to group.
u = user(username="test", save=True)
u.groups.add(self.g)
profile(user=u)
# Create site-wide and group announcements and dashboard.
announcement().save()
content = "stardate 12341"
announcement(group=self.g, content=content).save()
# Log in and check response.
self.client.login(username="test", password="testpass")
response = self.client.get(reverse("dashboards.group", args=[self.g.pk]), follow=True)
eq_(200, response.status_code)
doc = pq(response.content)
# The locale dash tab shows up.
eq_(4, len(doc("#user-nav li")))
# The locale dash tabs shows up and is active
eq_(u"A group", doc("#user-nav li.selected").text())
# The subtitle shows French.
eq_(u"Deutsch", doc("article h2.subtitle").text())
# The correct announcement shows up.
self.assertContains(response, content)
示例5: test_loggedin_preferred_language
def test_loggedin_preferred_language(self):
u = user(save=True)
profile(user=u, locale="zh-CN")
self.client.login(username=u.username, password="testpass")
response = self.client.get("/", follow=True)
self.assertRedirects(response, "/zh-CN/home")
self.client.logout()
response = self.client.get("/", follow=True, HTTP_ACCEPT_LANGUAGE="xx")
self.assertRedirects(response, "/xx/home")
示例6: test_POST
def test_POST(self, get_current):
get_current.return_value.domain = "testserver.com"
u = user(save=True, email="[email protected]", is_active=True)
profile(user=u) # save=True is forced.
r = self.client.post(reverse("users.forgot_username"), {"email": u.email})
eq_(302, r.status_code)
eq_("http://testserver/en-US/users/login", r["location"])
# Verify email
eq_(1, len(mail.outbox))
assert mail.outbox[0].subject.find("Your username on") == 0
assert mail.outbox[0].body.find(u.username) > 0
示例7: _setup_announcement
def _setup_announcement(self, visible_dates=True):
g = group(save=True)
u1 = user(save=True)
u2 = user(save=True)
u1.groups.add(g)
u2.groups.add(g)
# Create profiles for these users
profile(user=u1)
profile(user=u2)
self.user = u2
return announcement(creator=u1, group=g, save=True,
visible_dates=visible_dates)
示例8: test_POST
def test_POST(self, get_current):
get_current.return_value.domain = 'testserver.com'
u = user(save=True, email='[email protected]', is_active=True)
profile(user=u) # save=True is forced.
r = self.client.post(reverse('users.forgot_username'),
{'email': u.email})
eq_(302, r.status_code)
eq_('http://testserver/en-US/users/login', r['location'])
# Verify email
eq_(1, len(mail.outbox))
assert mail.outbox[0].subject.find('Your username on') == 0
assert mail.outbox[0].body.find(u.username) > 0
示例9: questionvote
def questionvote(**kwargs):
defaults = dict(created=datetime.now())
defaults.update(kwargs)
if "question" not in kwargs and "queation_id" not in kwargs:
defaults["question"] = question(save=True)
if "creator" not in kwargs and "creator_id" not in kwargs:
defaults["creator"] = profile().user
return QuestionVote(**defaults)
示例10: test_anonymous_change_to_login
def test_anonymous_change_to_login(self):
u = user(save=True)
profile(user=u, locale="zh-CN")
# anonymous is fr
self.client.get("/?lang=fr", follow=True)
response = self.client.get("/", follow=True)
self.assertRedirects(response, "/fr/home")
# logged in is zh-CN
self.client.login(username=u.username, password="testpass")
response = self.client.get("/", follow=True)
self.assertRedirects(response, "/zh-CN/home")
# anonymous again, session is now destroyed
self.client.logout()
response = self.client.get("/", follow=True, HTTP_ACCEPT_LANGUAGE="xx")
self.assertRedirects(response, "/xx/home")
示例11: test_num_documents
def test_num_documents(self):
"""Verify the number of documents contributed by user."""
u = profile().user
revision(creator=u, save=True)
revision(creator=u, save=True)
r = self.client.get(reverse('users.profile', args=[u.id]))
eq_(200, r.status_code)
assert '2 documents' in r.content
示例12: setUp
def setUp(self):
self.timezone = timezone('US/Pacific')
self.locale = 'en_US'
url_ = reverse('forums.threads', args=['testslug'])
self.context = {'request': test_utils.RequestFactory().get(url_)}
self.context['request'].locale = self.locale
user_profile = profile(timezone=self.timezone, locale=self.locale)
self.context['request'].user = user_profile
self.context['request'].user.is_authenticated = Mock(return_value=True)
self.context['request'].session = {'timezone': self.timezone}
示例13: test_ga_custom_variable_on_registered_login
def test_ga_custom_variable_on_registered_login(self):
"""After logging in, there should be a ga-push data attr on body."""
user_ = profile().user
# User should be "Registered":
response = self.client.post(
reverse("users.login"), {"username": user_.username, "password": "testpass"}, follow=True
)
eq_(200, response.status_code)
doc = pq(response.content)
assert '"Registered"' in doc("body").attr("data-ga-push")
示例14: test_ga_custom_variable_on_admin_login
def test_ga_custom_variable_on_admin_login(self):
"""After logging in, there should be a ga-push data attr on body."""
user_ = profile().user
# Add user to Administrators and so should be "Contributor - Admin":
user_.groups.add(group(name="Administrators", save=True))
response = self.client.post(
reverse("users.login"), {"username": user_.username, "password": "testpass"}, follow=True
)
eq_(200, response.status_code)
doc = pq(response.content)
assert '"Contributor - Admin"' in doc("body").attr("data-ga-push")
示例15: test_ga_custom_variable_on_registered_login
def test_ga_custom_variable_on_registered_login(self):
"""After logging in, there should be a ga-push data attr on body."""
user_ = profile().user
# User should be "Registered":
response = self.client.post(reverse('users.login'),
{'username': user_.username,
'password': 'testpass'},
follow=True)
eq_(200, response.status_code)
doc = pq(response.content)
assert '"Registered"' in doc('body').attr('data-ga-push')