本文整理汇总了Python中kitsune.questions.tests.QuestionFactory.delete方法的典型用法代码示例。如果您正苦于以下问题:Python QuestionFactory.delete方法的具体用法?Python QuestionFactory.delete怎么用?Python QuestionFactory.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kitsune.questions.tests.QuestionFactory
的用法示例。
在下文中一共展示了QuestionFactory.delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_question_no_answers_deleted
# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import delete [as 别名]
def test_question_no_answers_deleted(self):
search = QuestionMappingType.search()
q = QuestionFactory(title=u'Does this work?')
self.refresh()
eq_(search.query(question_title__match='work').count(), 1)
q.delete()
self.refresh()
eq_(search.query(question_title__match='work').count(), 0)
示例2: test_delete_question_removes_flag
# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import delete [as 别名]
def test_delete_question_removes_flag(self):
"""Deleting a question also removes the flags on that question."""
q = QuestionFactory(title='Test Question', content='Lorem Ipsum Dolor')
u = UserFactory()
FlaggedObject.objects.create(
status=0, content_object=q, reason='language', creator_id=u.id)
eq_(1, FlaggedObject.objects.count())
q.delete()
eq_(0, FlaggedObject.objects.count())
示例3: test_num_questions
# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import delete [as 别名]
def test_num_questions(self):
"""Answers are counted correctly on a user."""
u = UserFactory()
eq_(num_questions(u), 0)
q1 = QuestionFactory(creator=u)
eq_(num_questions(u), 1)
q2 = QuestionFactory(creator=u)
eq_(num_questions(u), 2)
q1.delete()
eq_(num_questions(u), 1)
q2.delete()
eq_(num_questions(u), 0)
示例4: test_question_one_answer_deleted
# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import delete [as 别名]
def test_question_one_answer_deleted(self):
search = QuestionMappingType.search()
q = QuestionFactory(title=u'are model makers the new pink?')
a = AnswerFactory(content=u'yes.', question=q)
self.refresh()
# Question and its answers are a single document--so the index count should be only 1.
eq_(search.query(question_title__match='pink').count(), 1)
# After deleting the answer, the question document should remain.
a.delete()
self.refresh()
eq_(search.query(question_title__match='pink').count(), 1)
# Delete the question and it should be removed from the index.
q.delete()
self.refresh()
eq_(search.query(question_title__match='pink').count(), 0)
示例5: TestQuestionUpdates
# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import delete [as 别名]
class TestQuestionUpdates(TestCaseBase):
"""Tests that questions are only updated in the right cases."""
client_class = LocalizingClient
date_format = '%Y%M%d%H%m%S'
def setUp(self):
super(TestQuestionUpdates, self).setUp()
self.u = UserFactory(is_superuser=True)
self.client.login(username=self.u.username, password='testpass')
self.q = QuestionFactory(updated=datetime(2012, 7, 9, 9, 0, 0))
self.a = AnswerFactory(question=self.q)
# Get the question from the database so we have a consistent level of
# precision during the test.
self.q = Question.objects.get(pk=self.q.id)
def tearDown(self):
self.client.logout()
self.u.delete()
self.q.delete()
def _request_and_no_update(self, url, req_type='POST', data={}):
updated = self.q.updated
if req_type == 'POST':
self.client.post(url, data, follow=True)
elif req_type == 'GET':
self.client.get(url, data, follow=True)
else:
raise ValueError('req_type must be either "GET" or "POST"')
self.q = Question.objects.get(pk=self.q.id)
eq_(updated.strftime(self.date_format),
self.q.updated.strftime(self.date_format))
def test_no_update_edit(self):
url = urlparams(reverse('questions.edit_question', args=[self.q.id]))
self._request_and_no_update(url, req_type='POST', data={
'title': 'A new title.',
'content': 'Some new content.'
})
def test_no_update_solve(self):
url = urlparams(reverse('questions.solve',
args=[self.q.id, self.a.id]))
self._request_and_no_update(url)
def test_no_update_unsolve(self):
url = urlparams(reverse('questions.unsolve',
args=[self.q.id, self.a.id]))
self._request_and_no_update(url)
def test_no_update_vote(self):
url = urlparams(reverse('questions.vote', args=[self.q.id]))
self._request_and_no_update(url, req_type='POST')
def test_no_update_lock(self):
url = urlparams(reverse('questions.lock', args=[self.q.id]))
self._request_and_no_update(url, req_type='POST')
# Now unlock
self._request_and_no_update(url, req_type='POST')
def test_no_update_tagging(self):
url = urlparams(reverse('questions.add_tag', args=[self.q.id]))
self._request_and_no_update(url, req_type='POST', data={
'tag-name': 'foo'
})
url = urlparams(reverse('questions.remove_tag', args=[self.q.id]))
self._request_and_no_update(url, req_type='POST', data={
'remove-tag-foo': 1
})