本文整理汇总了Python中kitsune.questions.tests.QuestionFactory.take方法的典型用法代码示例。如果您正苦于以下问题:Python QuestionFactory.take方法的具体用法?Python QuestionFactory.take怎么用?Python QuestionFactory.take使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kitsune.questions.tests.QuestionFactory
的用法示例。
在下文中一共展示了QuestionFactory.take方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_take_twice_forced
# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import take [as 别名]
def test_take_twice_forced(self):
u1 = UserFactory()
u2 = UserFactory()
q = QuestionFactory()
q.take(u1)
q.take(u2, force=True)
eq_(q.taken_by, u2)
示例2: test_is_taken
# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import take [as 别名]
def test_is_taken(self):
q = QuestionFactory()
u = UserFactory()
q.take(u)
url = reverse('question-detail', args=[q.id])
res = self.client.get(url)
eq_(res.status_code, 200)
eq_(res.data['taken_by']['username'], u.username)
示例3: test_filter_taken_by_username
# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import take [as 别名]
def test_filter_taken_by_username(self):
q1 = QuestionFactory()
q2 = QuestionFactory()
q2.take(q1.creator)
url = reverse('question-list') + '?taken_by=' + q1.creator.username
res = self.client.get(url)
eq_(res.status_code, 200)
eq_(res.data['count'], 1)
eq_(res.data['results'][0]['id'], q2.id)
示例4: test_filter_is_taken_false
# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import take [as 别名]
def test_filter_is_taken_false(self):
q1 = QuestionFactory()
q2 = QuestionFactory()
q2.take(q1.creator)
url = reverse('question-list') + '?is_taken=0'
res = self.client.get(url)
eq_(res.status_code, 200)
eq_(res.data['count'], 1)
eq_(res.data['results'][0]['id'], q1.id)
示例5: test_taken_until_is_set
# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import take [as 别名]
def test_taken_until_is_set(self):
u = UserFactory()
q = QuestionFactory()
q.take(u)
assert q.taken_until > datetime.now()
示例6: test_take_twice_same_user_refreshes_time
# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import take [as 别名]
def test_take_twice_same_user_refreshes_time(self):
u = UserFactory()
first_taken_until = datetime.now() - timedelta(minutes=5)
q = QuestionFactory(taken_by=u, taken_until=first_taken_until)
q.take(u)
ok_(q.taken_until > first_taken_until)
示例7: test_take_twice_fails
# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import take [as 别名]
def test_take_twice_fails(self):
u1 = UserFactory()
u2 = UserFactory()
q = QuestionFactory()
q.take(u1)
q.take(u2)
示例8: test_take_creator
# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import take [as 别名]
def test_take_creator(self):
q = QuestionFactory()
q.take(q.creator)
示例9: test_take
# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import take [as 别名]
def test_take(self):
u = UserFactory()
q = QuestionFactory()
q.take(u)
eq_(q.taken_by, u)
ok_(q.taken_until is not None)