本文整理汇总了Python中sumo.tests.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: common_answer_vote
def common_answer_vote(self):
"""Helper method for answer vote tests."""
# Check that there are no votes and vote form renders
response = get(self.client, 'questions.answers',
args=[self.question.id])
doc = pq(response.content)
eq_(1, len(doc('form.helpful input[name="helpful"]')))
# Vote
post(self.client, 'questions.answer_vote', {'helpful': 'y'},
args=[self.question.id, self.answer.id])
# Check that there is 1 vote and vote form doesn't render
response = get(self.client, 'questions.answers',
args=[self.question.id])
doc = pq(response.content)
eq_('1 out of 1 person', doc('#answer-1 div.helpful mark')[0].text)
eq_(0, len(doc('form.helpful input[name="helpful"]')))
# Voting again (same user) should not increment vote count
post(self.client, 'questions.answer_vote', {'helpful': 'y'},
args=[self.question.id, self.answer.id])
doc = pq(response.content)
eq_('1 out of 1 person', doc('#answer-1 div.helpful mark')[0].text)
开发者ID:MechanisM,项目名称:kitsune,代码行数:25,代码来源:test_templates.py
示例2: test_top_contributors
def test_top_contributors(self):
# There should be no top contributors since there are no solutions.
cache_top_contributors()
response = get(self.client, 'questions.questions')
doc = pq(response.content)
eq_(0, len(doc('#top-contributors ol li')))
# Solve a question and verify we now have a top conributor.
answer = Answer.objects.all()[0]
answer.created = datetime.now()
answer.save()
answer.question.solution = answer
answer.question.save()
cache_top_contributors()
response = get(self.client, 'questions.questions')
doc = pq(response.content)
lis = doc('#top-contributors ol li')
eq_(1, len(lis))
eq_('pcraciunoiu', lis[0].text)
# Make answer 8 days old. There should no be top contributors.
answer.created = datetime.now() - timedelta(days=8)
answer.save()
cache_top_contributors()
response = get(self.client, 'questions.questions')
doc = pq(response.content)
eq_(0, len(doc('#top-contributors ol li')))
开发者ID:MechanisM,项目名称:kitsune,代码行数:27,代码来源:test_templates.py
示例3: common_answer_vote
def common_answer_vote(self):
"""Helper method for answer vote tests."""
# Check that there are no votes and vote form renders
response = get(self.client, 'questions.answers',
args=[self.question.id])
doc = pq(response.content)
eq_(1, len(doc('form.helpful input[name="helpful"]')))
# Vote
ua = 'Mozilla/5.0 (DjangoTestClient)'
self.client.post(reverse('questions.answer_vote',
args=[self.question.id, self.answer.id]),
{'helpful': 'y'}, HTTP_USER_AGENT=ua)
# Check that there is 1 vote and vote form doesn't render
response = get(self.client, 'questions.answers',
args=[self.question.id])
doc = pq(response.content)
eq_('1 out of 1 person found this reply helpful',
doc('#answer-1 span.helpful')[0].text.strip())
eq_(0, len(doc('form.helpful input[name="helpful"]')))
# Verify user agent
vote_meta = VoteMetadata.objects.all()[0]
eq_('ua', vote_meta.key)
eq_(ua, vote_meta.value)
# Voting again (same user) should not increment vote count
post(self.client, 'questions.answer_vote', {'helpful': 'y'},
args=[self.question.id, self.answer.id])
doc = pq(response.content)
eq_('1 out of 1 person found this reply helpful',
doc('#answer-1 span.helpful')[0].text.strip())
开发者ID:bowmasters,项目名称:kitsune,代码行数:33,代码来源:test_templates.py
示例4: common_vote
def common_vote(self):
"""Helper method for question vote tests."""
# Check that there are no votes and vote form renders
response = get(self.client, 'questions.answers',
args=[self.question.id])
doc = pq(response.content)
eq_('0 people', doc('div.have-problem mark')[0].text)
eq_(1, len(doc('div.me-too form')))
# Vote
post(self.client, 'questions.vote', args=[self.question.id])
# Check that there is 1 vote and vote form doesn't render
response = get(self.client, 'questions.answers',
args=[self.question.id])
doc = pq(response.content)
eq_('1 person', doc('div.have-problem mark')[0].text)
eq_(0, len(doc('div.me-too form')))
# Voting again (same user) should not increment vote count
post(self.client, 'questions.vote', args=[self.question.id])
response = get(self.client, 'questions.answers',
args=[self.question.id])
doc = pq(response.content)
eq_('1 person', doc('div.have-problem mark')[0].text)
开发者ID:MechanisM,项目名称:kitsune,代码行数:25,代码来源:test_templates.py
示例5: test_delete_post_belongs_to_thread_and_forum
def test_delete_post_belongs_to_thread_and_forum(self):
"""
Delete post action - post belongs to thread and thread belongs to
forum.
"""
f = forum(save=True)
t = thread(forum=f, save=True)
# Post belongs to a different forum and thread.
p = forum_post(save=True)
u = p.author
# Give the user the permission to delete posts.
g = group(save=True)
ct = ContentType.objects.get_for_model(f)
permission(codename='forums_forum.post_delete_forum',
content_type=ct, object_id=p.thread.forum_id, group=g,
save=True)
permission(codename='forums_forum.post_delete_forum',
content_type=ct, object_id=f.id, group=g, save=True)
g.user_set.add(u)
self.client.login(username=u.username, password='testpass')
# Post isn't in the passed forum:
r = get(self.client, 'forums.delete_post',
args=[f.slug, p.thread.id, p.id])
eq_(404, r.status_code)
# Post isn't in the passed thread:
r = get(self.client, 'forums.delete_post',
args=[p.thread.forum.slug, t.id, p.id])
eq_(404, r.status_code)
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:32,代码来源:test_urls.py
示例6: common_vote
def common_vote(self):
"""Helper method for question vote tests."""
# Check that there are no votes and vote form renders
response = get(self.client, 'questions.answers',
args=[self.question.id])
doc = pq(response.content)
eq_('0 people', doc('div.have-problem mark')[0].text)
eq_(1, len(doc('div.me-too form')))
# Vote
ua = 'Mozilla/5.0 (DjangoTestClient)'
self.client.post(reverse('questions.vote', args=[self.question.id]),
{}, HTTP_USER_AGENT=ua)
# Check that there is 1 vote and vote form doesn't render
response = get(self.client, 'questions.answers',
args=[self.question.id])
doc = pq(response.content)
eq_('1 person', doc('div.have-problem mark')[0].text)
eq_(0, len(doc('div.me-too form')))
# Verify user agent
vote_meta = VoteMetadata.objects.all()[0]
eq_('ua', vote_meta.key)
eq_(ua, vote_meta.value)
# Voting again (same user) should not increment vote count
post(self.client, 'questions.vote', args=[self.question.id])
response = get(self.client, 'questions.answers',
args=[self.question.id])
doc = pq(response.content)
eq_('1 person', doc('div.have-problem mark')[0].text)
开发者ID:bowmasters,项目名称:kitsune,代码行数:31,代码来源:test_templates.py
示例7: test_delete_post_belongs_to_thread_and_forum
def test_delete_post_belongs_to_thread_and_forum(self):
"""
Delete post action - post belongs to thread and thread belongs to
forum.
"""
r = get(self.client, 'forums.delete_post',
args=[self.forum_2.slug, self.thread.id, self.post.id])
eq_(404, r.status_code)
r = get(self.client, 'forums.delete_post',
args=[self.forum.slug, self.thread_2.id, self.post.id])
eq_(404, r.status_code)
开发者ID:chengwang,项目名称:kitsune,代码行数:12,代码来源:test_urls.py
示例8: test_delete_post_belongs_to_thread_and_document
def test_delete_post_belongs_to_thread_and_document(self):
"""
Delete post action - post belongs to thread and thread belongs to
forum.
"""
r = get(self.client, 'wiki.discuss.delete_post',
args=[self.doc_2.slug, self.thread.id, self.post.id])
eq_(404, r.status_code)
r = get(self.client, 'wiki.discuss.delete_post',
args=[self.doc.slug, self.thread_2.id, self.post.id])
eq_(404, r.status_code)
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:12,代码来源:test_urls.py
示例9: test_num_replies
def test_num_replies(self):
"""Verify the number of replies label."""
t = forum_post(save=True).thread
response = get(self.client, 'forums.posts', args=[t.forum.slug, t.id])
eq_(200, response.status_code)
assert '0 Replies' in response.content
forum_post(thread=t, save=True)
forum_post(thread=t, save=True)
response = get(self.client, 'forums.posts', args=[t.forum.slug, t.id])
eq_(200, response.status_code)
assert '2 Replies' in response.content
开发者ID:LASarkar,项目名称:kitsune,代码行数:14,代码来源:test_templates.py
示例10: test_edit_answer_without_permission
def test_edit_answer_without_permission(self):
"""Editing an answer without permissions returns a 403.
The edit link shouldn't show up on the Answers page."""
response = get(self.client, "questions.answers", args=[self.question.id])
doc = pq(response.content)
eq_(0, len(doc("ol.answers li.edit")))
answer = self.question.last_answer
response = get(self.client, "questions.edit_answer", args=[self.question.id, answer.id])
eq_(403, response.status_code)
content = "New content for answer"
response = post(self.client, "questions.edit_answer", {"content": content}, args=[self.question.id, answer.id])
eq_(403, response.status_code)
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:15,代码来源:test_templates.py
示例11: test_delete_question_without_permissions
def test_delete_question_without_permissions(self):
"""Deleting a question without permissions is a 403."""
self.client.login(username="tagger", password="testpass")
response = get(self.client, "questions.delete", args=[self.question.id])
eq_(403, response.status_code)
response = post(self.client, "questions.delete", args=[self.question.id])
eq_(403, response.status_code)
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:7,代码来源:test_templates.py
示例12: test_long_title_truncated_in_crumbs
def test_long_title_truncated_in_crumbs(self):
"""A very long thread title gets truncated in the breadcrumbs"""
forum = Forum.objects.filter()[0]
response = get(self.client, 'forums.posts', args=[forum.slug, 4])
doc = pq(response.content)
crumb = doc('ol.breadcrumbs li:last-child')
eq_(crumb.text(), 'A thread with a very very ...')
开发者ID:GPHemsley,项目名称:kuma,代码行数:7,代码来源:test_templates.py
示例13: test_last_post_link_has_post_id
def test_last_post_link_has_post_id(self):
"""Make sure the last post url links to the last post (#post-<id>)."""
response = get(self.client, 'forums.forums')
doc = pq(response.content)
last_post_link = doc('ol.forums div.last-post a:not(.username)')[0]
href = last_post_link.attrib['href']
eq_(href.split('#')[1], 'post-25')
开发者ID:GPHemsley,项目名称:kuma,代码行数:7,代码来源:test_templates.py
示例14: test_edit_locked_thread_403
def test_edit_locked_thread_403(self):
"""Editing a locked thread returns 403."""
jsocol = User.objects.get(username='jsocol')
t = self.forum.thread_set.filter(creator=jsocol, is_locked=True)[0]
response = get(self.client, 'forums.edit_thread',
args=[self.forum.slug, t.id])
eq_(403, response.status_code)
开发者ID:MechanisM,项目名称:kitsune,代码行数:7,代码来源:test_templates.py
示例15: test_answer_creator_can_edit
def test_answer_creator_can_edit(self):
"""The creator of an answer can edit his/her answer."""
self.client.login(username="rrosario", password="testpass")
# Initially there should be no edit links
response = get(self.client, "questions.answers", args=[self.question.id])
doc = pq(response.content)
eq_(0, len(doc("ol.answers li.edit")))
# Add an answer and verify the edit link shows up
content = "lorem ipsum dolor sit amet"
response = post(self.client, "questions.reply", {"content": content}, args=[self.question.id])
doc = pq(response.content)
eq_(1, len(doc("ol.answers li.edit")))
new_answer = self.question.answers.order_by("-created")[0]
eq_(1, len(doc("#answer-%s li.edit" % new_answer.id)))
# Make sure it can be edited
content = "New content for answer"
response = post(
self.client, "questions.edit_answer", {"content": content}, args=[self.question.id, new_answer.id]
)
eq_(200, response.status_code)
# Now lock it and make sure it can't be edited
self.question.is_locked = True
self.question.save()
response = post(
self.client, "questions.edit_answer", {"content": content}, args=[self.question.id, new_answer.id]
)
eq_(403, response.status_code)
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:31,代码来源:test_templates.py
示例16: test_edit_locked_thread_403
def test_edit_locked_thread_403(self):
"""Editing a locked thread returns 403."""
t = thread(document=self.doc, creator=self.u, is_locked=True,
save=True)
response = get(self.client, 'wiki.discuss.edit_thread',
args=[self.doc.slug, t.id])
eq_(403, response.status_code)
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:7,代码来源:test_views.py
示例17: test_watch_solution
def test_watch_solution(self, get_current):
"""Watch a question for solution."""
self.client.logout()
get_current.return_value.domain = "testserver"
post(self.client, "questions.watch", {"email": "[email protected]", "event_type": "solution"}, args=[self.question.id])
assert QuestionSolvedEvent.is_notifying("[email protected]", self.question), "Watch was not created"
attrs_eq(mail.outbox[0], to=["[email protected]"], subject="Please confirm your email address")
assert "questions/confirm/" in mail.outbox[0].body
assert "Solution found" in mail.outbox[0].body
# Now activate the watch.
w = Watch.objects.get()
get(self.client, "questions.activate_watch", args=[w.id, w.secret])
assert Watch.objects.get().is_active
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:16,代码来源:test_templates.py
示例18: test_canonical_url
def test_canonical_url(self):
"""Verify the canonical URL is set correctly."""
f = forum(save=True)
response = get(self.client, 'forums.threads', args=[f.slug])
eq_('/forums/%s' % f.slug,
pq(response.content)('link[rel="canonical"]')[0].attrib['href'])
开发者ID:LASarkar,项目名称:kitsune,代码行数:7,代码来源:test_templates.py
示例19: test_read_without_permission
def test_read_without_permission(self):
"""Listing threads without the view_in_forum permission should 404."""
restricted_forum = _restricted_forum()
response = get(self.client, 'forums.threads',
args=[restricted_forum.slug])
eq_(404, response.status_code)
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:7,代码来源:test_views.py
示例20: test_posts_thread_belongs_to_forum
def test_posts_thread_belongs_to_forum(self):
"""Posts view - redirect if thread does notbelong to forum."""
r = get(self.client, 'forums.posts',
args=[self.forum_2.slug, self.thread.id])
eq_(200, r.status_code)
u = r.redirect_chain[0][0]
assert u.endswith(self.thread.get_absolute_url())
开发者ID:chengwang,项目名称:kitsune,代码行数:7,代码来源:test_urls.py
注:本文中的sumo.tests.get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论