本文整理汇总了Python中utils.login函数的典型用法代码示例。如果您正苦于以下问题:Python login函数的具体用法?Python login怎么用?Python login使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了login函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_topic_notification_list
def test_topic_notification_list(self):
"""
topic notification list
"""
utils.login(self)
response = self.client.get(reverse('spirit:topic-notification-list'))
self.assertQuerysetEqual(response.context['notifications'], map(repr, [self.topic_notification, ]))
示例2: setUp
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(10)
self.base_url = "http://127.0.0.1:8000"
self.verificationErrors = []
self.accept_next_alert = True
utils.login(self.driver)
示例3: test_private_publish_user
def test_private_publish_user(self):
"""
create private topic with user as initial value
"""
utils.login(self)
response = self.client.get(reverse('spirit:private-publish', kwargs={'user_id': self.user2.pk, }))
self.assertEqual(response.context['tpform'].initial['users'], [self.user2.username, ])
示例4: test_comment_move_signal
def test_comment_move_signal(self):
"""
move comments, emit signal
"""
self._comments = []
def comment_posted_handler(sender, comment, **kwargs):
self._comments.append(comment)
comment_posted.connect(comment_posted_handler)
def comment_moved_handler(sender, comments, topic_from, **kwargs):
self._comment_count = len(comments)
self._topic_from = topic_from
comment_moved.connect(comment_moved_handler)
utils.login(self)
self.user.is_moderator = True
self.user.save()
comment = utils.create_comment(user=self.user, topic=self.topic)
comment2 = utils.create_comment(user=self.user, topic=self.topic)
to_topic = utils.create_topic(self.category)
form_data = {'topic': to_topic.pk,
'comments': [comment.pk, comment2.pk], }
response = self.client.post(reverse('spirit:comment-move', kwargs={'topic_id': self.topic.pk, }),
form_data)
self.assertEqual(response.status_code, 302)
self.assertListEqual(self._comments, [comment2, comment])
self.assertEqual(self._comment_count, 2)
self.assertEqual(repr(self._topic_from), repr(self.topic))
示例5: test_private_publish_user
def test_private_publish_user(self):
"""
create private topic with user as initial value
"""
utils.login(self)
response = self.client.get(reverse("spirit:private-publish", kwargs={"user_id": self.user2.pk}))
self.assertEqual(response.context["tpform"].initial["users"], [self.user2.username])
示例6: test_user_admins
def test_user_admins(self):
"""
List of admins
"""
utils.login(self)
response = self.client.get(reverse('spirit:admin-user-admins'))
self.assertQuerysetEqual(response.context['users'], map(repr, [self.user, ]))
示例7: test_topic_publish_invalid_category
def test_topic_publish_invalid_category(self):
"""
invalid topic category
"""
utils.login(self)
response = self.client.get(reverse('spirit:topic-publish', kwargs={'category_id': str(99), }))
self.assertEqual(response.status_code, 404)
示例8: main
def main():
parser = get_argparser()
args = parser.parse_args()
username = args.email
password = args.password
blacklist = ['junk', 'trash', 'drafts']
if args.ignore:
blacklist.extend([b.lower() for b in args.ignore])
if not os.path.isdir('backup'):
os.makedirs('backup')
browser = webdriver.Firefox()
try:
login(browser, username, password)
mailboxes = get_mailboxes(browser, blacklist)
print('The following folders will be backed up:')
for box in mailboxes:
print(box)
for box in mailboxes:
print('Backing %s up' % box)
fetch_emails(browser, box)
print('%s backup complete!' % box)
finally:
browser.close()
print('Backup complete!')
示例9: test_profile_likes_dont_show_removed_or_private
def test_profile_likes_dont_show_removed_or_private(self):
"""
dont show private topics or removed
"""
category = utils.create_category()
category_removed = utils.create_category(is_removed=True)
subcategory = utils.create_category(parent=category_removed)
subcategory_removed = utils.create_category(parent=category, is_removed=True)
topic_a = utils.create_private_topic(user=self.user2)
topic_b = utils.create_topic(category=category, is_removed=True)
topic_c = utils.create_topic(category=category_removed)
topic_d = utils.create_topic(category=subcategory)
topic_e = utils.create_topic(category=subcategory_removed)
comment_a = utils.create_comment(user=self.user2, topic=topic_a.topic)
comment_b = utils.create_comment(user=self.user, topic=topic_b)
comment_c = utils.create_comment(user=self.user, topic=topic_c)
comment_d = utils.create_comment(user=self.user, topic=topic_d)
comment_e = utils.create_comment(user=self.user, topic=topic_e)
like_a = CommentLike.objects.create(user=self.user2, comment=comment_a)
like_b = CommentLike.objects.create(user=self.user2, comment=comment_b)
like_c = CommentLike.objects.create(user=self.user2, comment=comment_c)
like_d = CommentLike.objects.create(user=self.user2, comment=comment_d)
like_e = CommentLike.objects.create(user=self.user2, comment=comment_e)
utils.login(self)
response = self.client.get(reverse("spirit:profile-likes", kwargs={'pk': self.user2.pk,
'slug': self.user2.slug}))
self.assertQuerysetEqual(response.context['comments'], [])
示例10: test_advanced_search_detail
def test_advanced_search_detail(self):
"""
advanced search by topic
"""
utils.login(self)
response = self.client.get(reverse('spirit:search'))
self.assertEqual(response.status_code, 200)
示例11: test_user_mods
def test_user_mods(self):
"""
List of admins
"""
mod = utils.create_user(is_moderator=True)
utils.login(self)
response = self.client.get(reverse('spirit:admin-user-mods'))
self.assertQuerysetEqual(response.context['users'], map(repr, [mod, ]))
示例12: test_topic_pinned
def test_topic_pinned(self):
"""
Pinned topics
"""
topic_ = utils.create_topic(self.category, is_pinned=True)
utils.login(self)
response = self.client.get(reverse('spirit:admin-topic-pinned'))
self.assertQuerysetEqual(response.context['topics'], map(repr, [topic_, ]))
示例13: test_register_next_logged_in
def test_register_next_logged_in(self):
"""
redirect next on register
"""
# redirect logged in user
utils.login(self)
response = self.client.get(reverse('spirit:user-register') + "?next=/fakepath/")
self.assertRedirects(response, '/fakepath/', status_code=302, target_status_code=404)
示例14: test_resend_activation_email_redirect_logged
def test_resend_activation_email_redirect_logged(self):
"""
resend_activation_email redirect to profile if user is logged in
"""
utils.login(self)
response = self.client.get(reverse('spirit:resend-activation'))
expected_url = reverse("spirit:profile-update")
self.assertRedirects(response, expected_url, status_code=302)
示例15: test_private_detail
def test_private_detail(self):
"""
private topic detail
"""
utils.login(self)
private = utils.create_private_topic(user=self.user)
response = self.client.get(reverse("spirit:private-detail", kwargs={"topic_id": private.topic.pk}))
self.assertEqual(response.context["topic"], private.topic)