本文整理汇总了Python中misago.threads.testutils.reply_thread函数的典型用法代码示例。如果您正苦于以下问题:Python reply_thread函数的具体用法?Python reply_thread怎么用?Python reply_thread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reply_thread函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_category_prune_by_last_reply
def test_category_prune_by_last_reply(self):
"""command prunes category content based on last reply date"""
category = Category.objects.all_categories()[:1][0]
category.prune_replied_after = 20
category.save()
# post old threads with recent replies
started_on = timezone.now() - timedelta(days=30)
for t in range(10):
thread = testutils.post_thread(category, started_on=started_on)
testutils.reply_thread(thread)
# post recent threads that will be preserved
threads = [testutils.post_thread(category) for t in range(10)]
category.synchronize()
self.assertEqual(category.threads, 20)
self.assertEqual(category.posts, 30)
# run command
command = prunecategories.Command()
out = StringIO()
command.execute(stdout=out)
category.synchronize()
self.assertEqual(category.threads, 10)
self.assertEqual(category.posts, 10)
for thread in threads:
category.thread_set.get(id=thread.id)
command_output = out.getvalue().strip()
self.assertEqual(command_output, 'Categories were pruned')
开发者ID:l0ud,项目名称:Misago,代码行数:35,代码来源:test_prunecategories.py
示例2: test_filled_threads_list
def test_filled_threads_list(self):
"""filled threads list is rendered"""
forum = Forum.objects.all_forums().filter(role="forum")[:1][0]
threads = [testutils.post_thread(forum) for t in xrange(10)]
# only unread tracker threads are shown on unread list
response = self.client.get(reverse('misago:unread_threads'))
self.assertEqual(response.status_code, 200)
self.assertIn("There are no threads with unread", response.content)
# we'll read and reply to first five threads
for thread in threads[5:]:
response = self.client.get(thread.get_absolute_url())
testutils.reply_thread(thread, posted_on=timezone.now())
# assert that replied threads show on list
response = self.client.get(reverse('misago:unread_threads'))
self.assertEqual(response.status_code, 200)
for thread in threads[5:]:
self.assertIn(thread.get_absolute_url(), response.content)
for thread in threads[:5]:
self.assertNotIn(thread.get_absolute_url(), response.content)
# clear list
response = self.client.post(reverse('misago:clear_unread_threads'))
self.assertEqual(response.status_code, 302)
response = self.client.get(response['location'])
self.assertEqual(response.status_code, 200)
self.assertIn("There are no threads with unread", response.content)
开发者ID:Backenkoehler,项目名称:Misago,代码行数:30,代码来源:test_unreadthreads_view.py
示例3: setUp
def setUp(self):
super(ThreadPostSplitApiTestCase, self).setUp()
self.category = Category.objects.get(slug='first-category')
self.thread = testutils.post_thread(category=self.category)
self.posts = [
testutils.reply_thread(self.thread).pk, testutils.reply_thread(self.thread).pk
]
self.api_link = reverse(
'misago:api:thread-post-split', kwargs={
'thread_pk': self.thread.pk,
}
)
Category(
name='Category B',
slug='category-b',
).insert_at(
self.category,
position='last-child',
save=True,
)
self.category_b = Category.objects.get(slug='category-b')
self.override_acl()
self.override_other_acl()
开发者ID:dasdsadadaddasa,项目名称:PythonScientists,代码行数:27,代码来源:test_thread_postsplit_api.py
示例4: test_new
def test_new(self):
"""new returns link to first unread post"""
self.user.new_threads = MockThreadsCounter()
self.user.unread_threads = MockThreadsCounter()
post_link = goto.new(self.user, self.thread, self.thread.post_set)
last_link = goto.last(self.thread, self.thread.post_set)
self.assertEqual(post_link, last_link)
# add 18 posts to add extra page to thread, then read them
[reply_thread(self.thread) for p in xrange(18)]
threadstracker.read_thread(
self.user, self.thread, self.thread.last_post)
# add extra unread posts
first_unread = reply_thread(self.thread)
[reply_thread(self.thread) for p in xrange(30)]
new_link = goto.new(self.user, self.thread, self.thread.post_set)
post_link = goto.get_post_link(
50, self.thread.post_set, self.thread, first_unread)
self.assertEqual(new_link, post_link)
# read thread
threadstracker.read_thread(
self.user, self.thread, self.thread.last_post)
# assert new() points to last reply
post_link = goto.new(self.user, self.thread, self.thread.post_set)
last_link = goto.last(self.thread, self.thread.post_set)
self.assertEqual(post_link, last_link)
开发者ID:ChristosChristofidis,项目名称:Misago,代码行数:31,代码来源:test_goto.py
示例5: test_merge_posts
def test_merge_posts(self):
"""moderation allows for merging multiple posts into one"""
posts = []
for p in xrange(4):
posts.append(reply_thread(self.thread, poster=self.user))
for p in xrange(4):
posts.append(reply_thread(self.thread))
self.thread.synchronize()
self.assertEqual(self.thread.replies, 8)
test_acl = {
'can_merge_posts': 1
}
self.override_acl(test_acl)
response = self.client.get(self.thread.get_absolute_url())
self.assertEqual(response.status_code, 200)
self.assertIn("Merge posts into one", response.content)
self.override_acl(test_acl)
response = self.client.post(self.thread.get_absolute_url(), data={
'action': 'merge', 'item': [p.pk for p in posts[:1]]
})
self.assertEqual(response.status_code, 200)
self.assertIn("select at least two posts", response.content)
thread = Thread.objects.get(pk=self.thread.pk)
self.assertEqual(thread.replies, 8)
self.override_acl(test_acl)
response = self.client.post(self.thread.get_absolute_url(), data={
'action': 'merge', 'item': [p.pk for p in posts[3:5]]
})
self.assertEqual(response.status_code, 200)
self.assertIn("merge posts made by different authors",
response.content)
thread = Thread.objects.get(pk=self.thread.pk)
self.assertEqual(thread.replies, 8)
self.override_acl(test_acl)
response = self.client.post(self.thread.get_absolute_url(), data={
'action': 'merge', 'item': [p.pk for p in posts[5:7]]
})
self.assertEqual(response.status_code, 200)
self.assertIn("merge posts made by different authors",
response.content)
thread = Thread.objects.get(pk=self.thread.pk)
self.assertEqual(thread.replies, 8)
self.override_acl(test_acl)
response = self.client.post(self.thread.get_absolute_url(), data={
'action': 'merge', 'item': [p.pk for p in posts[:4]]
})
self.assertEqual(response.status_code, 302)
thread = Thread.objects.get(pk=self.thread.pk)
self.assertEqual(thread.replies, 5)
开发者ID:Backenkoehler,项目名称:Misago,代码行数:60,代码来源:test_thread_view.py
示例6: test_move_posts
def test_move_posts(self):
"""api moves posts to other thread"""
self.override_other_acl({'can_reply_threads': 1})
other_thread = testutils.post_thread(self.category_b)
posts = (
testutils.reply_thread(self.thread).pk, testutils.reply_thread(self.thread).pk,
testutils.reply_thread(self.thread).pk, testutils.reply_thread(self.thread).pk,
)
self.refresh_thread()
self.assertEqual(self.thread.replies, 4)
response = self.client.post(
self.api_link,
json.dumps({
'thread_url': other_thread.get_absolute_url(),
'posts': posts,
}),
content_type="application/json",
)
self.assertEqual(response.status_code, 200)
# replies were moved
self.refresh_thread()
self.assertEqual(self.thread.replies, 0)
other_thread = Thread.objects.get(pk=other_thread.pk)
self.assertEqual(other_thread.post_set.filter(pk__in=posts).count(), 4)
self.assertEqual(other_thread.replies, 4)
开发者ID:dasdsadadaddasa,项目名称:PythonScientists,代码行数:31,代码来源:test_thread_postmove_api.py
示例7: test_approve_posts
def test_approve_posts(self):
"""moderation allows for approving multiple posts"""
posts = []
for p in xrange(4):
posts.append(reply_thread(self.thread, is_moderated=True))
for p in xrange(4):
posts.append(reply_thread(self.thread))
self.assertTrue(self.reload_thread().has_moderated_posts)
self.assertEqual(self.thread.replies, 4)
test_acl = {
'can_review_moderated_content': 1
}
self.override_acl(test_acl)
response = self.client.get(self.thread.get_absolute_url())
self.assertEqual(response.status_code, 200)
self.assertIn("Approve posts", response.content)
self.override_acl(test_acl)
response = self.client.post(self.thread.get_absolute_url(), data={
'action': 'approve', 'item': [p.pk for p in posts]
})
self.assertEqual(response.status_code, 302)
self.assertFalse(self.reload_thread().has_moderated_posts)
self.assertEqual(self.reload_thread().replies, 8)
for post in posts:
self.assertFalse(self.thread.post_set.get(id=post.id).is_moderated)
开发者ID:Backenkoehler,项目名称:Misago,代码行数:31,代码来源:test_thread_view.py
示例8: test_forum_prune_by_last_reply
def test_forum_prune_by_last_reply(self):
"""command prunes forum content based on last reply date"""
forum = Forum.objects.all_forums().filter(role="forum")[:1][0]
forum.prune_replied_after = 20
forum.save()
# post old threads with recent replies
started_on = timezone.now() - timedelta(days=30)
for t in xrange(10):
thread = testutils.post_thread(forum, started_on=started_on)
testutils.reply_thread(thread)
# post recent threads that will be preserved
threads = [testutils.post_thread(forum) for t in xrange(10)]
forum.synchronize()
self.assertEqual(forum.threads, 20)
self.assertEqual(forum.posts, 30)
# run command
command = pruneforums.Command()
out = StringIO()
command.execute(stdout=out)
forum.synchronize()
self.assertEqual(forum.threads, 10)
self.assertEqual(forum.posts, 10)
for thread in threads:
forum.thread_set.get(id=thread.id)
command_output = out.getvalue().strip()
self.assertEqual(command_output, 'Forums were pruned')
开发者ID:Backenkoehler,项目名称:Misago,代码行数:35,代码来源:test_pruneforums.py
示例9: test_middleware_counts_unread_thread
def test_middleware_counts_unread_thread(self):
"""middleware counts thread with unread reply, post read flags user for recount"""
self.user.sync_unread_private_threads = True
self.user.save()
self.client.post(self.thread.last_post.get_read_api_url())
# post read zeroed list of unread private threads
self.reload_user()
self.assertFalse(self.user.sync_unread_private_threads)
self.assertEqual(self.user.unread_private_threads, 0)
# reply to thread
testutils.reply_thread(self.thread)
self.user.sync_unread_private_threads = True
self.user.save()
# middleware did recount and accounted for new unread post
response = self.client.get('/')
self.assertEqual(response.status_code, 200)
self.reload_user()
self.assertFalse(self.user.sync_unread_private_threads)
self.assertEqual(self.user.unread_private_threads, 1)
开发者ID:dasdsadadaddasa,项目名称:PythonScientists,代码行数:25,代码来源:test_sync_unread_private_threads.py
示例10: test_delete_posts
def test_delete_posts(self):
"""moderation allows for deleting posts"""
posts = [reply_thread(self.thread) for t in xrange(10)]
self.thread.synchronize()
self.assertEqual(self.thread.replies, 10)
test_acl = {
'can_hide_posts': 2
}
self.override_acl(test_acl)
response = self.client.get(self.thread.get_absolute_url())
self.assertEqual(response.status_code, 200)
self.assertIn("Delete posts", response.content)
self.override_acl(test_acl)
response = self.client.post(self.thread.get_absolute_url(), data={
'action': 'delete', 'item': [p.pk for p in posts]
})
self.assertEqual(response.status_code, 302)
self.assertTrue(
response['location'].endswith(self.thread.get_absolute_url()))
thread = Thread.objects.get(pk=self.thread.pk)
self.assertEqual(thread.replies, 0)
posts = [reply_thread(self.thread) for t in xrange(30)]
second_page_link = reverse('misago:thread', kwargs={
'thread_id': self.thread.id,
'thread_slug': self.thread.slug,
'page': 2
})
self.override_acl(test_acl)
response = self.client.post(second_page_link, data={
'action': 'delete', 'item': [p.pk for p in posts[10:20]]
})
self.assertEqual(response.status_code, 302)
self.assertTrue(response['location'].endswith(second_page_link))
thread = Thread.objects.get(pk=self.thread.pk)
self.assertEqual(thread.replies, 20)
self.override_acl(test_acl)
response = self.client.post(second_page_link, data={
'action': 'delete', 'item': [p.pk for p in posts[:-10]]
})
self.assertEqual(response.status_code, 302)
self.assertTrue(
response['location'].endswith(self.thread.get_absolute_url()))
thread = Thread.objects.get(pk=self.thread.pk)
self.assertEqual(thread.replies, 10)
开发者ID:jinchaoh,项目名称:Misago,代码行数:55,代码来源:test_thread_view.py
示例11: test_moderated_list
def test_moderated_list(self):
"""moderated posts list works"""
self.override_acl({'can_review_moderated_content': True})
response = self.client.get(self.thread.get_moderated_url(),
**self.ajax_header)
self.assertEqual(response.status_code, 200)
self.assertIn("0 unapproved posts", response.content)
self.assertIn("There are no posts to display on this list.",
response.content)
# post 10 not moderated posts
[reply_thread(self.thread) for i in xrange(10)]
# assert that posts don't show
self.override_acl({'can_review_moderated_content': True})
response = self.client.get(self.thread.get_moderated_url(),
**self.ajax_header)
self.assertEqual(response.status_code, 200)
self.assertIn("0 unapproved posts", response.content)
self.assertIn("There are no posts to display on this list.",
response.content)
# post 10 reported posts
posts = []
for i in xrange(10):
posts.append(reply_thread(self.thread, is_moderated=True))
# assert that posts show
self.override_acl({'can_review_moderated_content': True})
response = self.client.get(self.thread.get_moderated_url(),
**self.ajax_header)
self.assertEqual(response.status_code, 200)
self.assertIn("10 unapproved posts", response.content)
self.assertNotIn("There are no posts to display on this list.",
response.content)
for post in posts:
self.assertIn(post.get_absolute_url(), response.content)
# overflow list via posting extra 20 reported posts
posts = []
for i in xrange(20):
posts.append(reply_thread(self.thread, is_moderated=True))
# assert that posts don't show
self.override_acl({'can_review_moderated_content': True})
response = self.client.get(self.thread.get_moderated_url(),
**self.ajax_header)
self.assertEqual(response.status_code, 200)
self.assertIn("30 unapproved posts", response.content)
self.assertIn("This list is limited to last 15 posts.",
response.content)
for post in posts[15:]:
self.assertIn(post.get_absolute_url(), response.content)
开发者ID:Backenkoehler,项目名称:Misago,代码行数:55,代码来源:test_gotolists_views.py
示例12: test_get_post_page
def test_get_post_page(self):
"""get_post_page returns valid page number for given queryset"""
self.assertEqual(goto.get_post_page(1, self.thread.post_set), 1)
# add 12 posts, bumping no of posts on page to to 13
[reply_thread(self.thread) for p in xrange(12)]
self.assertEqual(goto.get_post_page(13, self.thread.post_set), 1)
# add 2 posts
[reply_thread(self.thread) for p in xrange(2)]
self.assertEqual(goto.get_post_page(15, self.thread.post_set), 2)
开发者ID:nikescar,项目名称:Misago,代码行数:11,代码来源:test_goto.py
示例13: test_get_post_page
def test_get_post_page(self):
"""get_post_page returns valid page number for given queryset"""
self.assertEqual(goto.get_post_page(1, self.thread.post_set), 1)
# fill out page
[reply_thread(self.thread) for p in xrange(MAX_PAGE_LEN - 1)]
self.assertEqual(
goto.get_post_page(MAX_PAGE_LEN, self.thread.post_set), 1)
# add 2 posts, adding second page
[reply_thread(self.thread) for p in xrange(2)]
self.assertEqual(
goto.get_post_page(MAX_PAGE_LEN + 2, self.thread.post_set), 2)
开发者ID:Backenkoehler,项目名称:Misago,代码行数:13,代码来源:test_goto.py
示例14: test_category_archive_by_start_date
def test_category_archive_by_start_date(self):
"""command archives category content based on start date"""
category = Category.objects.all_categories()[:1][0]
archive = Category.objects.create(
lft=7,
rght=8,
tree_id=2,
level=0,
name='Archive',
slug='archive',
)
category.prune_started_after = 20
category.archive_pruned_in = archive
category.save()
# post old threads with recent replies
started_on = timezone.now() - timedelta(days=30)
posted_on = timezone.now()
for t in range(10):
thread = testutils.post_thread(category, started_on=started_on)
testutils.reply_thread(thread, posted_on=posted_on)
# post recent threads that will be preserved
threads = [testutils.post_thread(category) for t in range(10)]
category.synchronize()
self.assertEqual(category.threads, 20)
self.assertEqual(category.posts, 30)
# run command
command = prunecategories.Command()
out = StringIO()
command.execute(stdout=out)
category.synchronize()
self.assertEqual(category.threads, 10)
self.assertEqual(category.posts, 10)
archive.synchronize()
self.assertEqual(archive.threads, 10)
self.assertEqual(archive.posts, 20)
for thread in threads:
category.thread_set.get(id=thread.id)
command_output = out.getvalue().strip()
self.assertEqual(command_output, 'Categories were pruned')
开发者ID:l0ud,项目名称:Misago,代码行数:49,代码来源:test_prunecategories.py
示例15: setUp
def setUp(self):
super(PostBulkDeleteApiTests, self).setUp()
self.posts = [
testutils.reply_thread(self.thread, poster=self.user),
testutils.reply_thread(self.thread),
testutils.reply_thread(self.thread, poster=self.user),
]
self.api_link = reverse(
'misago:api:thread-post-list',
kwargs={
'thread_pk': self.thread.pk,
}
)
开发者ID:dasdsadadaddasa,项目名称:PythonScientists,代码行数:15,代码来源:test_thread_postbulkdelete_api.py
示例16: test_reply_to_other_thread_post
def test_reply_to_other_thread_post(self):
"""api validates is replied post belongs to same thread"""
other_thread = testutils.post_thread(category=self.category)
reply_to = testutils.reply_thread(other_thread)
response = self.client.get('{}?reply={}'.format(self.api_link, reply_to.pk))
self.assertEqual(response.status_code, 404)
开发者ID:dasdsadadaddasa,项目名称:PythonScientists,代码行数:7,代码来源:test_threads_editor_api.py
示例17: test_unapproved_post_visibility
def test_unapproved_post_visibility(self):
"""unapproved post renders for its author and users with perm to approve content"""
post = testutils.reply_thread(self.thread, is_unapproved=True)
# post is hdden because we aren't its author nor user with permission to approve
response = self.client.get(self.thread.get_absolute_url())
self.assertNotContains(response, post.get_absolute_url())
# post displays because we have permission to approve unapproved content
self.override_acl({'can_approve_content': 1})
response = self.client.get(self.thread.get_absolute_url())
self.assertContains(response, post.get_absolute_url())
self.assertContains(response, "This post is unapproved.")
self.assertContains(response, post.parsed)
# post displays because we are its author
post.poster = self.user
post.save()
self.override_acl({'can_approve_content': 0})
response = self.client.get(self.thread.get_absolute_url())
self.assertContains(response, post.get_absolute_url())
self.assertContains(response, "This post is unapproved.")
self.assertContains(response, post.parsed)
开发者ID:dasdsadadaddasa,项目名称:PythonScientists,代码行数:26,代码来源:test_threadview.py
示例18: test_posts_not_found
def test_posts_not_found(self):
"""api fails to find posts"""
posts = [
testutils.reply_thread(self.thread, is_hidden=True),
testutils.reply_thread(self.thread, is_unapproved=True),
]
response = self.patch(self.api_link, {
'ids': [p.id for p in posts],
'ops': [{}],
})
self.assertEqual(response.status_code, 403)
self.assertEqual(response.json(), {
'detail': "One or more posts to update could not be found.",
})
开发者ID:dasdsadadaddasa,项目名称:PythonScientists,代码行数:16,代码来源:test_thread_postbulkpatch_api.py
示例19: create_thread
def create_thread(self):
datetime = timezone.now()
thread = testutils.post_thread(self.forum)
post = testutils.reply_thread(thread)
return thread
开发者ID:dahito,项目名称:Misago,代码行数:7,代码来源:test_forum_model.py
示例20: test_steal_attachments
def test_steal_attachments(self):
"""middleware validates if attachments are already assigned to other posts"""
other_post = testutils.reply_thread(self.thread)
attachments = [
self.mock_attachment(post=other_post),
self.mock_attachment(),
]
middleware = AttachmentsMiddleware(
request=RequestMock({
'attachments': [attachments[0].pk, attachments[1].pk]
}),
mode=PostingEndpoint.EDIT,
user=self.user,
post=self.post,
)
serializer = middleware.get_serializer()
self.assertTrue(serializer.is_valid())
middleware.save(serializer)
# only unassociated attachment was associated with post
self.assertEqual(self.post.update_fields, ['attachments_cache'])
self.assertEqual(self.post.attachment_set.count(), 1)
self.assertEqual(Attachment.objects.get(pk=attachments[0].pk).post, other_post)
self.assertEqual(Attachment.objects.get(pk=attachments[1].pk).post, self.post)
开发者ID:dasdsadadaddasa,项目名称:PythonScientists,代码行数:28,代码来源:test_attachments_middleware.py
注:本文中的misago.threads.testutils.reply_thread函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论