mirror of
https://github.com/QingdaoU/Spirit.git
synced 2024-12-28 23:41:59 +00:00
Fix F841 errors of unused local variables
This commit is contained in:
parent
451316bdec
commit
d3e79660e8
@ -1,4 +1,4 @@
|
|||||||
[flake8]
|
[flake8]
|
||||||
exclude=.git,migrations/,*settings*.py
|
exclude=.git,migrations/,*settings*.py
|
||||||
ignore=E123,E128,E265,E501,W601,F841
|
ignore=E123,E128,E265,E501,W601
|
||||||
max-line-length = 119
|
max-line-length = 119
|
||||||
|
@ -26,7 +26,7 @@ def poll_update(request, pk):
|
|||||||
|
|
||||||
if form.is_valid() and formset.is_valid():
|
if form.is_valid() and formset.is_valid():
|
||||||
poll = form.save()
|
poll = form.save()
|
||||||
choices = formset.save()
|
formset.save()
|
||||||
return redirect(request.POST.get('next', poll.get_absolute_url()))
|
return redirect(request.POST.get('next', poll.get_absolute_url()))
|
||||||
else:
|
else:
|
||||||
form = TopicPollForm(instance=poll)
|
form = TopicPollForm(instance=poll)
|
||||||
|
@ -141,7 +141,7 @@ class AdminViewTest(TestCase):
|
|||||||
"""
|
"""
|
||||||
Categories, excludes Topic Private and subcats
|
Categories, excludes Topic Private and subcats
|
||||||
"""
|
"""
|
||||||
subcat = utils.create_category(parent=self.category)
|
utils.create_category(parent=self.category)
|
||||||
categories = Category.objects.filter(is_private=False, parent=None)
|
categories = Category.objects.filter(is_private=False, parent=None)
|
||||||
utils.login(self)
|
utils.login(self)
|
||||||
response = self.client.get(reverse('spirit:admin-category-list'))
|
response = self.client.get(reverse('spirit:admin-category-list'))
|
||||||
@ -195,7 +195,7 @@ class AdminViewTest(TestCase):
|
|||||||
"""
|
"""
|
||||||
comment = utils.create_comment(topic=self.topic)
|
comment = utils.create_comment(topic=self.topic)
|
||||||
comment2 = utils.create_comment(topic=self.topic)
|
comment2 = utils.create_comment(topic=self.topic)
|
||||||
flag_closed = CommentFlag.objects.create(comment=comment2, is_closed=True)
|
CommentFlag.objects.create(comment=comment2, is_closed=True)
|
||||||
flag_ = CommentFlag.objects.create(comment=comment)
|
flag_ = CommentFlag.objects.create(comment=comment)
|
||||||
|
|
||||||
utils.login(self)
|
utils.login(self)
|
||||||
@ -209,7 +209,7 @@ class AdminViewTest(TestCase):
|
|||||||
comment = utils.create_comment(topic=self.topic)
|
comment = utils.create_comment(topic=self.topic)
|
||||||
comment2 = utils.create_comment(topic=self.topic)
|
comment2 = utils.create_comment(topic=self.topic)
|
||||||
flag_closed = CommentFlag.objects.create(comment=comment2, is_closed=True)
|
flag_closed = CommentFlag.objects.create(comment=comment2, is_closed=True)
|
||||||
flag_ = CommentFlag.objects.create(comment=comment)
|
CommentFlag.objects.create(comment=comment)
|
||||||
|
|
||||||
utils.login(self)
|
utils.login(self)
|
||||||
response = self.client.get(reverse('spirit:admin-flag-closed'))
|
response = self.client.get(reverse('spirit:admin-flag-closed'))
|
||||||
@ -224,8 +224,8 @@ class AdminViewTest(TestCase):
|
|||||||
flag_ = Flag.objects.create(comment=comment, user=self.user, reason=0)
|
flag_ = Flag.objects.create(comment=comment, user=self.user, reason=0)
|
||||||
|
|
||||||
comment2 = utils.create_comment(topic=self.topic)
|
comment2 = utils.create_comment(topic=self.topic)
|
||||||
comment_flag2 = CommentFlag.objects.create(comment=comment2)
|
CommentFlag.objects.create(comment=comment2)
|
||||||
flag_2 = Flag.objects.create(comment=comment2, user=self.user, reason=0)
|
Flag.objects.create(comment=comment2, user=self.user, reason=0)
|
||||||
|
|
||||||
utils.login(self)
|
utils.login(self)
|
||||||
form_data = {"is_closed": True, }
|
form_data = {"is_closed": True, }
|
||||||
|
@ -53,7 +53,7 @@ class CategoryViewTest(TestCase):
|
|||||||
"""
|
"""
|
||||||
topic_a = utils.create_topic(category=self.category_1, is_pinned=True)
|
topic_a = utils.create_topic(category=self.category_1, is_pinned=True)
|
||||||
topic_b = utils.create_topic(category=self.category_1)
|
topic_b = utils.create_topic(category=self.category_1)
|
||||||
topic_c = utils.create_topic(category=self.category_1, is_pinned=True, is_removed=True)
|
utils.create_topic(category=self.category_1, is_pinned=True, is_removed=True)
|
||||||
# show pinned first
|
# show pinned first
|
||||||
Topic.objects.filter(pk=topic_a.pk).update(last_active=timezone.now() - datetime.timedelta(days=10))
|
Topic.objects.filter(pk=topic_a.pk).update(last_active=timezone.now() - datetime.timedelta(days=10))
|
||||||
|
|
||||||
@ -66,9 +66,9 @@ class CategoryViewTest(TestCase):
|
|||||||
should not display removed topics or from other categories
|
should not display removed topics or from other categories
|
||||||
"""
|
"""
|
||||||
subcategory_removed = utils.create_subcategory(self.category_1, is_removed=True)
|
subcategory_removed = utils.create_subcategory(self.category_1, is_removed=True)
|
||||||
topic_removed = utils.create_topic(category=subcategory_removed)
|
utils.create_topic(category=subcategory_removed)
|
||||||
topic_removed2 = utils.create_topic(category=self.category_1, is_removed=True)
|
utils.create_topic(category=self.category_1, is_removed=True)
|
||||||
topic_bad = utils.create_topic(category=self.category_2)
|
utils.create_topic(category=self.category_2)
|
||||||
|
|
||||||
response = self.client.get(reverse('spirit:category-detail', kwargs={'pk': self.category_1.pk,
|
response = self.client.get(reverse('spirit:category-detail', kwargs={'pk': self.category_1.pk,
|
||||||
'slug': self.category_1.slug}))
|
'slug': self.category_1.slug}))
|
||||||
@ -101,7 +101,7 @@ class CategoryViewTest(TestCase):
|
|||||||
"""
|
"""
|
||||||
should display all topics in subcategory
|
should display all topics in subcategory
|
||||||
"""
|
"""
|
||||||
topic = utils.create_topic(category=self.category_1)
|
utils.create_topic(category=self.category_1)
|
||||||
topic2 = utils.create_topic(category=self.subcategory_1, title="topic_subcat1")
|
topic2 = utils.create_topic(category=self.subcategory_1, title="topic_subcat1")
|
||||||
response = self.client.get(reverse('spirit:category-detail', kwargs={'pk': self.subcategory_1.pk,
|
response = self.client.get(reverse('spirit:category-detail', kwargs={'pk': self.subcategory_1.pk,
|
||||||
'slug': self.subcategory_1.slug}))
|
'slug': self.subcategory_1.slug}))
|
||||||
|
@ -160,8 +160,7 @@ class CommentViewTest(TestCase):
|
|||||||
|
|
||||||
utils.login(self)
|
utils.login(self)
|
||||||
form_data = {'comment': 'foobar', }
|
form_data = {'comment': 'foobar', }
|
||||||
response = self.client.post(reverse('spirit:comment-publish', kwargs={'topic_id': self.topic.pk, }),
|
self.client.post(reverse('spirit:comment-publish', kwargs={'topic_id': self.topic.pk, }), form_data)
|
||||||
form_data)
|
|
||||||
self.assertEqual(self._comment.comment, 'foobar')
|
self.assertEqual(self._comment.comment, 'foobar')
|
||||||
|
|
||||||
def test_comment_publish_quote(self):
|
def test_comment_publish_quote(self):
|
||||||
@ -249,8 +248,8 @@ class CommentViewTest(TestCase):
|
|||||||
utils.login(self)
|
utils.login(self)
|
||||||
comment_posted = utils.create_comment(user=self.user, topic=self.topic)
|
comment_posted = utils.create_comment(user=self.user, topic=self.topic)
|
||||||
form_data = {'comment': 'barfoo', }
|
form_data = {'comment': 'barfoo', }
|
||||||
response = self.client.post(reverse('spirit:comment-update', kwargs={'pk': comment_posted.pk, }),
|
self.client.post(reverse('spirit:comment-update', kwargs={'pk': comment_posted.pk, }),
|
||||||
form_data)
|
form_data)
|
||||||
self.assertEqual(repr(self._comment_new), repr(Comment.objects.get(pk=comment_posted.pk)))
|
self.assertEqual(repr(self._comment_new), repr(Comment.objects.get(pk=comment_posted.pk)))
|
||||||
self.assertEqual(repr(self._comment_old), repr(comment_posted))
|
self.assertEqual(repr(self._comment_old), repr(comment_posted))
|
||||||
|
|
||||||
@ -458,7 +457,7 @@ class CommentTemplateTagTests(TestCase):
|
|||||||
"""
|
"""
|
||||||
should display simple comment form
|
should display simple comment form
|
||||||
"""
|
"""
|
||||||
out = Template(
|
Template(
|
||||||
"{% load spirit_tags %}"
|
"{% load spirit_tags %}"
|
||||||
"{% render_comments_form topic %}"
|
"{% render_comments_form topic %}"
|
||||||
).render(Context({'topic': self.topic, }))
|
).render(Context({'topic': self.topic, }))
|
||||||
|
@ -26,7 +26,7 @@ class CommentHistoryViewTest(TestCase):
|
|||||||
comment = utils.create_comment(user=self.user, topic=self.topic)
|
comment = utils.create_comment(user=self.user, topic=self.topic)
|
||||||
comment_history = CommentHistory.objects.create(comment_fk=comment, comment_html=comment.comment_html)
|
comment_history = CommentHistory.objects.create(comment_fk=comment, comment_html=comment.comment_html)
|
||||||
comment2 = utils.create_comment(user=self.user, topic=self.topic)
|
comment2 = utils.create_comment(user=self.user, topic=self.topic)
|
||||||
comment_history2 = CommentHistory.objects.create(comment_fk=comment2, comment_html=comment2.comment_html)
|
CommentHistory.objects.create(comment_fk=comment2, comment_html=comment2.comment_html)
|
||||||
|
|
||||||
utils.login(self)
|
utils.login(self)
|
||||||
response = self.client.get(reverse('spirit:comment-history', kwargs={'comment_id': comment.pk, }))
|
response = self.client.get(reverse('spirit:comment-history', kwargs={'comment_id': comment.pk, }))
|
||||||
@ -38,7 +38,7 @@ class CommentHistoryViewTest(TestCase):
|
|||||||
"""
|
"""
|
||||||
private = utils.create_private_topic(user=self.user)
|
private = utils.create_private_topic(user=self.user)
|
||||||
comment = utils.create_comment(user=self.user, topic=private.topic)
|
comment = utils.create_comment(user=self.user, topic=private.topic)
|
||||||
comment_history = CommentHistory.objects.create(comment_fk=comment, comment_html=comment.comment_html)
|
CommentHistory.objects.create(comment_fk=comment, comment_html=comment.comment_html)
|
||||||
|
|
||||||
utils.login(self)
|
utils.login(self)
|
||||||
response = self.client.get(reverse('spirit:comment-history', kwargs={'comment_id': comment.pk, }))
|
response = self.client.get(reverse('spirit:comment-history', kwargs={'comment_id': comment.pk, }))
|
||||||
@ -52,14 +52,14 @@ class CommentHistoryViewTest(TestCase):
|
|||||||
|
|
||||||
# comment removed
|
# comment removed
|
||||||
comment = utils.create_comment(user=self.user, topic=self.topic, is_removed=True)
|
comment = utils.create_comment(user=self.user, topic=self.topic, is_removed=True)
|
||||||
comment_history = CommentHistory.objects.create(comment_fk=comment, comment_html=comment.comment_html)
|
CommentHistory.objects.create(comment_fk=comment, comment_html=comment.comment_html)
|
||||||
response = self.client.get(reverse('spirit:comment-history', kwargs={'comment_id': comment.pk, }))
|
response = self.client.get(reverse('spirit:comment-history', kwargs={'comment_id': comment.pk, }))
|
||||||
self.assertEqual(response.status_code, 404)
|
self.assertEqual(response.status_code, 404)
|
||||||
|
|
||||||
# topic removed
|
# topic removed
|
||||||
topic = utils.create_topic(category=self.category, user=self.user, is_removed=True)
|
topic = utils.create_topic(category=self.category, user=self.user, is_removed=True)
|
||||||
comment = utils.create_comment(user=self.user, topic=topic)
|
comment = utils.create_comment(user=self.user, topic=topic)
|
||||||
comment_history = CommentHistory.objects.create(comment_fk=comment, comment_html=comment.comment_html)
|
CommentHistory.objects.create(comment_fk=comment, comment_html=comment.comment_html)
|
||||||
response = self.client.get(reverse('spirit:comment-history', kwargs={'comment_id': comment.pk, }))
|
response = self.client.get(reverse('spirit:comment-history', kwargs={'comment_id': comment.pk, }))
|
||||||
self.assertEqual(response.status_code, 404)
|
self.assertEqual(response.status_code, 404)
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ class CommentHistoryViewTest(TestCase):
|
|||||||
category = utils.create_category(is_removed=True)
|
category = utils.create_category(is_removed=True)
|
||||||
topic = utils.create_topic(category=category, user=self.user)
|
topic = utils.create_topic(category=category, user=self.user)
|
||||||
comment = utils.create_comment(user=self.user, topic=topic)
|
comment = utils.create_comment(user=self.user, topic=topic)
|
||||||
comment_history = CommentHistory.objects.create(comment_fk=comment, comment_html=comment.comment_html)
|
CommentHistory.objects.create(comment_fk=comment, comment_html=comment.comment_html)
|
||||||
response = self.client.get(reverse('spirit:comment-history', kwargs={'comment_id': comment.pk, }))
|
response = self.client.get(reverse('spirit:comment-history', kwargs={'comment_id': comment.pk, }))
|
||||||
self.assertEqual(response.status_code, 404)
|
self.assertEqual(response.status_code, 404)
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ class CommentHistoryViewTest(TestCase):
|
|||||||
private.delete()
|
private.delete()
|
||||||
|
|
||||||
comment = utils.create_comment(user=self.user, topic=private.topic)
|
comment = utils.create_comment(user=self.user, topic=private.topic)
|
||||||
comment_history = CommentHistory.objects.create(comment_fk=comment, comment_html=comment.comment_html)
|
CommentHistory.objects.create(comment_fk=comment, comment_html=comment.comment_html)
|
||||||
|
|
||||||
utils.login(self)
|
utils.login(self)
|
||||||
response = self.client.get(reverse('spirit:comment-history', kwargs={'comment_id': comment.pk, }))
|
response = self.client.get(reverse('spirit:comment-history', kwargs={'comment_id': comment.pk, }))
|
||||||
|
@ -128,7 +128,7 @@ class LikeTemplateTagsTest(TestCase):
|
|||||||
"{% render_like_form comment=comment like=like %}"
|
"{% render_like_form comment=comment like=like %}"
|
||||||
)
|
)
|
||||||
data = {'comment': self.comment, 'like': None}
|
data = {'comment': self.comment, 'like': None}
|
||||||
out = template.render(Context(data))
|
template.render(Context(data))
|
||||||
context = render_like_form(**data)
|
context = render_like_form(**data)
|
||||||
self.assertEqual(context['next'], None)
|
self.assertEqual(context['next'], None)
|
||||||
self.assertIsInstance(context['form'], LikeForm)
|
self.assertIsInstance(context['form'], LikeForm)
|
||||||
@ -137,7 +137,7 @@ class LikeTemplateTagsTest(TestCase):
|
|||||||
|
|
||||||
like = CommentLike.objects.create(user=self.user, comment=self.comment)
|
like = CommentLike.objects.create(user=self.user, comment=self.comment)
|
||||||
data['like'] = like
|
data['like'] = like
|
||||||
out = template.render(Context(data))
|
template.render(Context(data))
|
||||||
context = render_like_form(**data)
|
context = render_like_form(**data)
|
||||||
self.assertEqual(context['like'], like)
|
self.assertEqual(context['like'], like)
|
||||||
|
|
||||||
|
@ -35,18 +35,18 @@ class SearchTopicIndexTest(TestCase):
|
|||||||
"""
|
"""
|
||||||
index_queryset should exclude private topics
|
index_queryset should exclude private topics
|
||||||
"""
|
"""
|
||||||
private = utils.create_private_topic()
|
utils.create_private_topic()
|
||||||
self.assertEqual(len(TopicIndex().index_queryset()), 0)
|
self.assertEqual(len(TopicIndex().index_queryset()), 0)
|
||||||
|
|
||||||
category = utils.create_category()
|
category = utils.create_category()
|
||||||
topic = utils.create_topic(category)
|
utils.create_topic(category)
|
||||||
self.assertEqual(len(TopicIndex().index_queryset()), 1)
|
self.assertEqual(len(TopicIndex().index_queryset()), 1)
|
||||||
|
|
||||||
def test_indexing_excludes_private_topics(self):
|
def test_indexing_excludes_private_topics(self):
|
||||||
"""
|
"""
|
||||||
rebuild_index command should exclude private topics
|
rebuild_index command should exclude private topics
|
||||||
"""
|
"""
|
||||||
private = utils.create_private_topic()
|
utils.create_private_topic()
|
||||||
category = utils.create_category()
|
category = utils.create_category()
|
||||||
topic = utils.create_topic(category)
|
topic = utils.create_topic(category)
|
||||||
call_command("rebuild_index", interactive=False)
|
call_command("rebuild_index", interactive=False)
|
||||||
@ -144,7 +144,7 @@ class SearchTemplateTagTests(TestCase):
|
|||||||
"""
|
"""
|
||||||
should display the basic search form
|
should display the basic search form
|
||||||
"""
|
"""
|
||||||
out = Template(
|
Template(
|
||||||
"{% load spirit_tags %}"
|
"{% load spirit_tags %}"
|
||||||
"{% render_search_form %}"
|
"{% render_search_form %}"
|
||||||
).render(Context())
|
).render(Context())
|
||||||
|
@ -182,8 +182,8 @@ class TopicViewTest(TestCase):
|
|||||||
topic = utils.create_topic(category=category, user=self.user)
|
topic = utils.create_topic(category=category, user=self.user)
|
||||||
category2 = utils.create_category()
|
category2 = utils.create_category()
|
||||||
form_data = {'title': 'foobar', 'category': category2.pk}
|
form_data = {'title': 'foobar', 'category': category2.pk}
|
||||||
response = self.client.post(reverse('spirit:topic-update', kwargs={'pk': topic.pk, }),
|
self.client.post(reverse('spirit:topic-update', kwargs={'pk': topic.pk, }),
|
||||||
form_data)
|
form_data)
|
||||||
self.assertSequenceEqual(self._moderate, [repr(self.user), repr(Topic.objects.get(pk=topic.pk)), MOVED])
|
self.assertSequenceEqual(self._moderate, [repr(self.user), repr(Topic.objects.get(pk=topic.pk)), MOVED])
|
||||||
|
|
||||||
def test_topic_update_invalid_user(self):
|
def test_topic_update_invalid_user(self):
|
||||||
@ -270,11 +270,11 @@ class TopicViewTest(TestCase):
|
|||||||
# show topic from regular category
|
# show topic from regular category
|
||||||
topic_a = utils.create_topic(category=category)
|
topic_a = utils.create_topic(category=category)
|
||||||
# dont show pinned from regular category
|
# dont show pinned from regular category
|
||||||
topic_b = utils.create_topic(category=category, is_pinned=True)
|
utils.create_topic(category=category, is_pinned=True)
|
||||||
|
|
||||||
uncat_category = Category.objects.get(pk=settings.ST_UNCATEGORIZED_CATEGORY_PK)
|
uncat_category = Category.objects.get(pk=settings.ST_UNCATEGORIZED_CATEGORY_PK)
|
||||||
# dont show pinned and removed
|
# dont show pinned and removed
|
||||||
topic_c = utils.create_topic(category=uncat_category, is_pinned=True, is_removed=True)
|
utils.create_topic(category=uncat_category, is_pinned=True, is_removed=True)
|
||||||
# show topic from uncategorized category
|
# show topic from uncategorized category
|
||||||
topic_d = utils.create_topic(category=uncat_category, is_pinned=True)
|
topic_d = utils.create_topic(category=uncat_category, is_pinned=True)
|
||||||
# show pinned first
|
# show pinned first
|
||||||
@ -296,11 +296,11 @@ class TopicViewTest(TestCase):
|
|||||||
category_removed = utils.create_category(is_removed=True)
|
category_removed = utils.create_category(is_removed=True)
|
||||||
subcategory = utils.create_category(parent=category_removed)
|
subcategory = utils.create_category(parent=category_removed)
|
||||||
subcategory_removed = utils.create_category(parent=category, is_removed=True)
|
subcategory_removed = utils.create_category(parent=category, is_removed=True)
|
||||||
topic_a = utils.create_private_topic()
|
utils.create_private_topic()
|
||||||
topic_b = utils.create_topic(category=category, is_removed=True)
|
utils.create_topic(category=category, is_removed=True)
|
||||||
topic_c = utils.create_topic(category=category_removed)
|
utils.create_topic(category=category_removed)
|
||||||
topic_d = utils.create_topic(category=subcategory)
|
utils.create_topic(category=subcategory)
|
||||||
topic_e = utils.create_topic(category=subcategory_removed)
|
utils.create_topic(category=subcategory_removed)
|
||||||
|
|
||||||
response = self.client.get(reverse('spirit:topic-active'))
|
response = self.client.get(reverse('spirit:topic-active'))
|
||||||
self.assertQuerysetEqual(response.context['topics'], [])
|
self.assertQuerysetEqual(response.context['topics'], [])
|
||||||
|
@ -91,16 +91,16 @@ class TopicNotificationViewTest(TestCase):
|
|||||||
topic_c = utils.create_topic(category=category_removed)
|
topic_c = utils.create_topic(category=category_removed)
|
||||||
topic_d = utils.create_topic(category=subcategory)
|
topic_d = utils.create_topic(category=subcategory)
|
||||||
topic_e = utils.create_topic(category=subcategory_removed)
|
topic_e = utils.create_topic(category=subcategory_removed)
|
||||||
unread_a = TopicNotification.objects.create(user=self.user, topic=topic_a.topic,
|
TopicNotification.objects.create(user=self.user, topic=topic_a.topic,
|
||||||
comment=self.comment, is_active=True, action=COMMENT)
|
comment=self.comment, is_active=True, action=COMMENT)
|
||||||
unread_b = TopicNotification.objects.create(user=self.user, topic=topic_b,
|
TopicNotification.objects.create(user=self.user, topic=topic_b,
|
||||||
comment=self.comment, is_active=True, action=COMMENT)
|
comment=self.comment, is_active=True, action=COMMENT)
|
||||||
unread_c = TopicNotification.objects.create(user=self.user, topic=topic_c,
|
TopicNotification.objects.create(user=self.user, topic=topic_c,
|
||||||
comment=self.comment, is_active=True, action=COMMENT)
|
comment=self.comment, is_active=True, action=COMMENT)
|
||||||
unread_d = TopicNotification.objects.create(user=self.user, topic=topic_d,
|
TopicNotification.objects.create(user=self.user, topic=topic_d,
|
||||||
comment=self.comment, is_active=True, action=COMMENT)
|
comment=self.comment, is_active=True, action=COMMENT)
|
||||||
unread_e = TopicNotification.objects.create(user=self.user, topic=topic_e,
|
TopicNotification.objects.create(user=self.user, topic=topic_e,
|
||||||
comment=self.comment, is_active=True, action=COMMENT)
|
comment=self.comment, is_active=True, action=COMMENT)
|
||||||
self.assertEqual(len(TopicNotification.objects.filter(user=self.user, is_active=True, is_read=False)), 5)
|
self.assertEqual(len(TopicNotification.objects.filter(user=self.user, is_active=True, is_read=False)), 5)
|
||||||
|
|
||||||
utils.login(self)
|
utils.login(self)
|
||||||
@ -458,16 +458,16 @@ class TopicNotificationTemplateTagsTest(TestCase):
|
|||||||
topic_c = utils.create_topic(category=category_removed)
|
topic_c = utils.create_topic(category=category_removed)
|
||||||
topic_d = utils.create_topic(category=subcategory)
|
topic_d = utils.create_topic(category=subcategory)
|
||||||
topic_e = utils.create_topic(category=subcategory_removed)
|
topic_e = utils.create_topic(category=subcategory_removed)
|
||||||
unread_a = TopicNotification.objects.create(user=self.user, topic=topic_a.topic,
|
TopicNotification.objects.create(user=self.user, topic=topic_a.topic,
|
||||||
comment=self.comment, is_active=True, action=COMMENT)
|
comment=self.comment, is_active=True, action=COMMENT)
|
||||||
unread_b = TopicNotification.objects.create(user=self.user, topic=topic_b,
|
TopicNotification.objects.create(user=self.user, topic=topic_b,
|
||||||
comment=self.comment, is_active=True, action=COMMENT)
|
comment=self.comment, is_active=True, action=COMMENT)
|
||||||
unread_c = TopicNotification.objects.create(user=self.user, topic=topic_c,
|
TopicNotification.objects.create(user=self.user, topic=topic_c,
|
||||||
comment=self.comment, is_active=True, action=COMMENT)
|
comment=self.comment, is_active=True, action=COMMENT)
|
||||||
unread_d = TopicNotification.objects.create(user=self.user, topic=topic_d,
|
TopicNotification.objects.create(user=self.user, topic=topic_d,
|
||||||
comment=self.comment, is_active=True, action=COMMENT)
|
comment=self.comment, is_active=True, action=COMMENT)
|
||||||
unread_e = TopicNotification.objects.create(user=self.user, topic=topic_e,
|
TopicNotification.objects.create(user=self.user, topic=topic_e,
|
||||||
comment=self.comment, is_active=True, action=COMMENT)
|
comment=self.comment, is_active=True, action=COMMENT)
|
||||||
|
|
||||||
self.assertEqual(len(TopicNotification.objects.filter(user=self.user, is_active=True, is_read=False)), 5)
|
self.assertEqual(len(TopicNotification.objects.filter(user=self.user, is_active=True, is_read=False)), 5)
|
||||||
self.assertFalse(has_topic_notifications(self.user))
|
self.assertFalse(has_topic_notifications(self.user))
|
||||||
@ -476,7 +476,7 @@ class TopicNotificationTemplateTagsTest(TestCase):
|
|||||||
"""
|
"""
|
||||||
should display the form
|
should display the form
|
||||||
"""
|
"""
|
||||||
out = Template(
|
Template(
|
||||||
"{% load spirit_tags %}"
|
"{% load spirit_tags %}"
|
||||||
"{% render_notification_form user topic %}"
|
"{% render_notification_form user topic %}"
|
||||||
).render(Context({'topic': self.topic, 'user': self.user}))
|
).render(Context({'topic': self.topic, 'user': self.user}))
|
||||||
|
@ -505,7 +505,7 @@ class TopicPollTemplateTagsTest(TestCase):
|
|||||||
should load initial or not
|
should load initial or not
|
||||||
"""
|
"""
|
||||||
poll_choice = TopicPollChoice.objects.create(poll=self.poll, description="op2")
|
poll_choice = TopicPollChoice.objects.create(poll=self.poll, description="op2")
|
||||||
poll_vote = TopicPollVote.objects.create(user=self.user, choice=poll_choice)
|
TopicPollVote.objects.create(user=self.user, choice=poll_choice)
|
||||||
|
|
||||||
self.user.is_authenticated = lambda: True
|
self.user.is_authenticated = lambda: True
|
||||||
context = render_poll_form(self.topic, self.user)
|
context = render_poll_form(self.topic, self.user)
|
||||||
|
@ -192,10 +192,10 @@ class TopicPrivateViewTest(TestCase):
|
|||||||
"""
|
"""
|
||||||
private = utils.create_private_topic(user=self.user)
|
private = utils.create_private_topic(user=self.user)
|
||||||
# dont show private topics from other users
|
# dont show private topics from other users
|
||||||
private2 = TopicPrivate.objects.create(user=self.user2, topic=private.topic)
|
TopicPrivate.objects.create(user=self.user2, topic=private.topic)
|
||||||
# dont show topics from other categories
|
# dont show topics from other categories
|
||||||
category = utils.create_category()
|
category = utils.create_category()
|
||||||
topic = utils.create_topic(category, user=self.user)
|
utils.create_topic(category, user=self.user)
|
||||||
|
|
||||||
utils.login(self)
|
utils.login(self)
|
||||||
response = self.client.get(reverse('spirit:private-list'))
|
response = self.client.get(reverse('spirit:private-list'))
|
||||||
@ -284,14 +284,14 @@ class TopicPrivateViewTest(TestCase):
|
|||||||
private topic created list, shows only the private topics the user is no longer participating
|
private topic created list, shows only the private topics the user is no longer participating
|
||||||
"""
|
"""
|
||||||
category = utils.create_category()
|
category = utils.create_category()
|
||||||
regular_topic = utils.create_topic(category, user=self.user)
|
utils.create_topic(category, user=self.user)
|
||||||
# it's the owner, left the topic
|
# it's the owner, left the topic
|
||||||
private = utils.create_private_topic(user=self.user)
|
private = utils.create_private_topic(user=self.user)
|
||||||
private.delete()
|
private.delete()
|
||||||
# has access and is the owner
|
# has access and is the owner
|
||||||
private2 = utils.create_private_topic(user=self.user)
|
utils.create_private_topic(user=self.user)
|
||||||
# does not has access
|
# does not has access
|
||||||
private3 = utils.create_private_topic(user=self.user2)
|
utils.create_private_topic(user=self.user2)
|
||||||
# has access but it's not owner
|
# has access but it's not owner
|
||||||
private4 = utils.create_private_topic(user=self.user2)
|
private4 = utils.create_private_topic(user=self.user2)
|
||||||
TopicPrivate.objects.create(user=self.user, topic=private4.topic)
|
TopicPrivate.objects.create(user=self.user, topic=private4.topic)
|
||||||
|
@ -71,11 +71,11 @@ class TopicUnreadViewTest(TestCase):
|
|||||||
topic_c = utils.create_topic(category=category_removed)
|
topic_c = utils.create_topic(category=category_removed)
|
||||||
topic_d = utils.create_topic(category=subcategory)
|
topic_d = utils.create_topic(category=subcategory)
|
||||||
topic_e = utils.create_topic(category=subcategory_removed)
|
topic_e = utils.create_topic(category=subcategory_removed)
|
||||||
unread_a = TopicUnread.objects.create(user=self.user, topic=topic_a.topic, is_read=False)
|
TopicUnread.objects.create(user=self.user, topic=topic_a.topic, is_read=False)
|
||||||
unread_b = TopicUnread.objects.create(user=self.user, topic=topic_b, is_read=False)
|
TopicUnread.objects.create(user=self.user, topic=topic_b, is_read=False)
|
||||||
unread_c = TopicUnread.objects.create(user=self.user, topic=topic_c, is_read=False)
|
TopicUnread.objects.create(user=self.user, topic=topic_c, is_read=False)
|
||||||
unread_d = TopicUnread.objects.create(user=self.user, topic=topic_d, is_read=False)
|
TopicUnread.objects.create(user=self.user, topic=topic_d, is_read=False)
|
||||||
unread_e = TopicUnread.objects.create(user=self.user, topic=topic_e, is_read=False)
|
TopicUnread.objects.create(user=self.user, topic=topic_e, is_read=False)
|
||||||
|
|
||||||
utils.login(self)
|
utils.login(self)
|
||||||
response = self.client.get(reverse('spirit:topic-unread-list'))
|
response = self.client.get(reverse('spirit:topic-unread-list'))
|
||||||
|
@ -142,11 +142,11 @@ class UserViewTest(TestCase):
|
|||||||
category_removed = utils.create_category(is_removed=True)
|
category_removed = utils.create_category(is_removed=True)
|
||||||
subcategory = utils.create_category(parent=category_removed)
|
subcategory = utils.create_category(parent=category_removed)
|
||||||
subcategory_removed = utils.create_category(parent=category, is_removed=True)
|
subcategory_removed = utils.create_category(parent=category, is_removed=True)
|
||||||
topic_a = utils.create_private_topic(user=self.user2)
|
utils.create_private_topic(user=self.user2)
|
||||||
topic_b = utils.create_topic(category=category, user=self.user2, is_removed=True)
|
utils.create_topic(category=category, user=self.user2, is_removed=True)
|
||||||
topic_c = utils.create_topic(category=category_removed, user=self.user2)
|
utils.create_topic(category=category_removed, user=self.user2)
|
||||||
topic_d = utils.create_topic(category=subcategory, user=self.user2)
|
utils.create_topic(category=subcategory, user=self.user2)
|
||||||
topic_e = utils.create_topic(category=subcategory_removed, user=self.user2)
|
utils.create_topic(category=subcategory_removed, user=self.user2)
|
||||||
|
|
||||||
utils.login(self)
|
utils.login(self)
|
||||||
response = self.client.get(reverse("spirit:profile-topics", kwargs={'pk': self.user2.pk,
|
response = self.client.get(reverse("spirit:profile-topics", kwargs={'pk': self.user2.pk,
|
||||||
@ -170,7 +170,7 @@ class UserViewTest(TestCase):
|
|||||||
"""
|
"""
|
||||||
utils.login(self)
|
utils.login(self)
|
||||||
comment = utils.create_comment(user=self.user2, topic=self.topic)
|
comment = utils.create_comment(user=self.user2, topic=self.topic)
|
||||||
comment2 = utils.create_comment(user=self.user, topic=self.topic)
|
utils.create_comment(user=self.user, topic=self.topic)
|
||||||
response = self.client.get(reverse("spirit:profile-detail", kwargs={'pk': self.user2.pk,
|
response = self.client.get(reverse("spirit:profile-detail", kwargs={'pk': self.user2.pk,
|
||||||
'slug': self.user2.slug}))
|
'slug': self.user2.slug}))
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
@ -206,11 +206,11 @@ class UserViewTest(TestCase):
|
|||||||
topic_c = utils.create_topic(category=category_removed)
|
topic_c = utils.create_topic(category=category_removed)
|
||||||
topic_d = utils.create_topic(category=subcategory)
|
topic_d = utils.create_topic(category=subcategory)
|
||||||
topic_e = utils.create_topic(category=subcategory_removed)
|
topic_e = utils.create_topic(category=subcategory_removed)
|
||||||
comment_a = utils.create_comment(user=self.user2, topic=topic_a.topic)
|
utils.create_comment(user=self.user2, topic=topic_a.topic)
|
||||||
comment_b = utils.create_comment(user=self.user2, topic=topic_b)
|
utils.create_comment(user=self.user2, topic=topic_b)
|
||||||
comment_c = utils.create_comment(user=self.user2, topic=topic_c)
|
utils.create_comment(user=self.user2, topic=topic_c)
|
||||||
comment_d = utils.create_comment(user=self.user2, topic=topic_d)
|
utils.create_comment(user=self.user2, topic=topic_d)
|
||||||
comment_e = utils.create_comment(user=self.user2, topic=topic_e)
|
utils.create_comment(user=self.user2, topic=topic_e)
|
||||||
|
|
||||||
utils.login(self)
|
utils.login(self)
|
||||||
response = self.client.get(reverse("spirit:profile-detail", kwargs={'pk': self.user2.pk,
|
response = self.client.get(reverse("spirit:profile-detail", kwargs={'pk': self.user2.pk,
|
||||||
@ -236,7 +236,7 @@ class UserViewTest(TestCase):
|
|||||||
comment = utils.create_comment(user=self.user, topic=self.topic)
|
comment = utils.create_comment(user=self.user, topic=self.topic)
|
||||||
comment2 = utils.create_comment(user=self.user2, topic=self.topic)
|
comment2 = utils.create_comment(user=self.user2, topic=self.topic)
|
||||||
like = CommentLike.objects.create(user=self.user2, comment=comment)
|
like = CommentLike.objects.create(user=self.user2, comment=comment)
|
||||||
like2 = CommentLike.objects.create(user=self.user, comment=comment2)
|
CommentLike.objects.create(user=self.user, comment=comment2)
|
||||||
response = self.client.get(reverse("spirit:profile-likes", kwargs={'pk': self.user2.pk,
|
response = self.client.get(reverse("spirit:profile-likes", kwargs={'pk': self.user2.pk,
|
||||||
'slug': self.user2.slug}))
|
'slug': self.user2.slug}))
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
@ -251,7 +251,7 @@ class UserViewTest(TestCase):
|
|||||||
comment_b = utils.create_comment(user=self.user, topic=self.topic)
|
comment_b = utils.create_comment(user=self.user, topic=self.topic)
|
||||||
comment_c = utils.create_comment(user=self.user, topic=self.topic)
|
comment_c = utils.create_comment(user=self.user, topic=self.topic)
|
||||||
like_a = CommentLike.objects.create(user=self.user2, comment=comment_a)
|
like_a = CommentLike.objects.create(user=self.user2, comment=comment_a)
|
||||||
like_b = CommentLike.objects.create(user=self.user2, comment=comment_b)
|
CommentLike.objects.create(user=self.user2, comment=comment_b)
|
||||||
like_c = CommentLike.objects.create(user=self.user2, comment=comment_c)
|
like_c = CommentLike.objects.create(user=self.user2, comment=comment_c)
|
||||||
|
|
||||||
CommentLike.objects.filter(pk=like_a.pk).update(date=timezone.now() - datetime.timedelta(days=10))
|
CommentLike.objects.filter(pk=like_a.pk).update(date=timezone.now() - datetime.timedelta(days=10))
|
||||||
@ -280,11 +280,11 @@ class UserViewTest(TestCase):
|
|||||||
comment_c = utils.create_comment(user=self.user, topic=topic_c)
|
comment_c = utils.create_comment(user=self.user, topic=topic_c)
|
||||||
comment_d = utils.create_comment(user=self.user, topic=topic_d)
|
comment_d = utils.create_comment(user=self.user, topic=topic_d)
|
||||||
comment_e = utils.create_comment(user=self.user, topic=topic_e)
|
comment_e = utils.create_comment(user=self.user, topic=topic_e)
|
||||||
like_a = CommentLike.objects.create(user=self.user2, comment=comment_a)
|
CommentLike.objects.create(user=self.user2, comment=comment_a)
|
||||||
like_b = CommentLike.objects.create(user=self.user2, comment=comment_b)
|
CommentLike.objects.create(user=self.user2, comment=comment_b)
|
||||||
like_c = CommentLike.objects.create(user=self.user2, comment=comment_c)
|
CommentLike.objects.create(user=self.user2, comment=comment_c)
|
||||||
like_d = CommentLike.objects.create(user=self.user2, comment=comment_d)
|
CommentLike.objects.create(user=self.user2, comment=comment_d)
|
||||||
like_e = CommentLike.objects.create(user=self.user2, comment=comment_e)
|
CommentLike.objects.create(user=self.user2, comment=comment_e)
|
||||||
|
|
||||||
utils.login(self)
|
utils.login(self)
|
||||||
response = self.client.get(reverse("spirit:profile-likes", kwargs={'pk': self.user2.pk,
|
response = self.client.get(reverse("spirit:profile-likes", kwargs={'pk': self.user2.pk,
|
||||||
@ -496,7 +496,7 @@ class UserViewTest(TestCase):
|
|||||||
"""
|
"""
|
||||||
resend_activation_email invalid password
|
resend_activation_email invalid password
|
||||||
"""
|
"""
|
||||||
user = utils.create_user(password="foo")
|
utils.create_user(password="foo")
|
||||||
|
|
||||||
form_data = {'email': "bad@foo.com", }
|
form_data = {'email': "bad@foo.com", }
|
||||||
response = self.client.post(reverse('spirit:resend-activation'),
|
response = self.client.post(reverse('spirit:resend-activation'),
|
||||||
|
@ -322,7 +322,7 @@ class UtilsMarkdownTests(TestCase):
|
|||||||
"""
|
"""
|
||||||
comment = "@nitely, @esteban"
|
comment = "@nitely, @esteban"
|
||||||
md = Markdown(escape=True, hard_wrap=True)
|
md = Markdown(escape=True, hard_wrap=True)
|
||||||
comment_md = md.render(comment)
|
md.render(comment)
|
||||||
# mentions get dianmically added on MentionifyExtension
|
# mentions get dianmically added on MentionifyExtension
|
||||||
self.assertDictEqual(md.get_mentions(), {'nitely': self.user,
|
self.assertDictEqual(md.get_mentions(), {'nitely': self.user,
|
||||||
'esteban': self.user2})
|
'esteban': self.user2})
|
||||||
|
@ -219,7 +219,7 @@ class UtilsYTPaginatorTemplateTagsTests(TestCase):
|
|||||||
req = RequestFactory().get('/')
|
req = RequestFactory().get('/')
|
||||||
items = list(range(0, 20))
|
items = list(range(0, 20))
|
||||||
page = YTPaginator(items, per_page=10).page(1)
|
page = YTPaginator(items, per_page=10).page(1)
|
||||||
out = Template(
|
Template(
|
||||||
"{% load spirit_tags %}"
|
"{% load spirit_tags %}"
|
||||||
"{% render_yt_paginator page %}"
|
"{% render_yt_paginator page %}"
|
||||||
).render(Context({'request': req, 'page': page, }))
|
).render(Context({'request': req, 'page': page, }))
|
||||||
@ -300,7 +300,7 @@ class UtilsPaginatorTemplateTagsTests(TestCase):
|
|||||||
req = RequestFactory().get('/')
|
req = RequestFactory().get('/')
|
||||||
items = list(range(0, 20))
|
items = list(range(0, 20))
|
||||||
page = Paginator(items, per_page=10).page(1)
|
page = Paginator(items, per_page=10).page(1)
|
||||||
out = Template(
|
Template(
|
||||||
"{% load spirit_tags %}"
|
"{% load spirit_tags %}"
|
||||||
"{% render_paginator page %}"
|
"{% render_paginator page %}"
|
||||||
).render(Context({'request': req, 'page': page, }))
|
).render(Context({'request': req, 'page': page, }))
|
||||||
|
Loading…
Reference in New Issue
Block a user