Exemple #1
0
 def test_comment_list_for_article_is_picked_up_through_publishable(self):
     create_comment(self.publishable, self.publishable.content_type)
     t = template.Template(
         '''{% load ellacomments_tags %}{% get_comment_list for obj as var_name%}{{ var_name|length }}'''
     )
     self.assert_equals(
         '1', t.render(template.Context({'obj': self.only_publishable})))
Exemple #2
0
 def test_default_comment_options_for_article(self):
     create_comment(self.publishable, self.publishable.content_type)
     t = template.Template(
         '''{% load ellacomments_tags %}{% get_comment_options for obj as opts %}{% if not opts.blocked %}XX{% endif %}'''
     )
     self.assert_equals(
         u'XX', t.render(template.Context({'obj': self.only_publishable})))
Exemple #3
0
 def test_get_list_renders_correct_comments(self):
     template_loader.templates['page/comment_list.html'] = ''
     c = create_comment(self.publishable, self.publishable.content_type)
     c2 = create_comment(self.publishable, self.publishable.content_type)
     response = self.client.get(self.get_url())
     self.assert_equals(200, response.status_code)
     self.assert_equals([c, c2], list(response.context['comment_list']))
Exemple #4
0
 def test_get_list_renders_correct_comments(self):
     template_loader.templates['page/comment_list.html'] = ''
     c = create_comment(self.publishable, self.publishable.content_type)
     c2 = create_comment(self.publishable, self.publishable.content_type)
     response = self.client.get(self.get_url())
     self.assert_equals(200, response.status_code)
     self.assert_equals([c, c2], list(response.context['comment_list']))
Exemple #5
0
 def test_post_works_for_correct_data_with_parent(self):
     c = create_comment(self.publishable, self.publishable.content_type)
     form = comments.get_form()(target_object=self.publishable, parent=c.pk)
     response = self.client.post(self.get_url('new'), self.get_form_data(form))
     self.assert_equals(302, response.status_code)
     self.assert_equals(2, comments.get_model().objects.count())
     child = comments.get_model().objects.exclude(pk=c.pk)[0]
     self.assert_equals(c, child.parent)
Exemple #6
0
 def test_post_passes_parent_on_get_to_template_if_specified(self):
     template_loader.templates['page/comment_form.html'] = ''
     c = create_comment(self.publishable, self.publishable.content_type)
     response = self.client.get(self.get_url('new', c.pk))
     self.assert_equals(200, response.status_code)
     self.assert_true('parent' in response.context)
     self.assert_equals(c, response.context['parent'])
     form =  response.context['form']
     self.assert_equals(str(c.pk), form.parent)
Exemple #7
0
 def test_post_passes_parent_on_get_to_template_if_specified(self):
     template_loader.templates['page/comment_form.html'] = ''
     c = create_comment(self.publishable, self.publishable.content_type)
     response = self.client.get(self.get_url('new', c.pk))
     self.assert_equals(200, response.status_code)
     self.assert_true('parent' in response.context)
     self.assert_equals(c, response.context['parent'])
     form = response.context['form']
     self.assert_equals(str(c.pk), form.parent)
Exemple #8
0
 def test_post_works_for_correct_data_with_parent(self):
     c = create_comment(self.publishable, self.publishable.content_type)
     form = comments.get_form()(target_object=self.publishable, parent=c.pk)
     response = self.client.post(self.get_url('new'),
                                 self.get_form_data(form))
     self.assert_equals(302, response.status_code)
     self.assert_equals(2, comments.get_model().objects.count())
     child = comments.get_model().objects.exclude(pk=c.pk)[0]
     self.assert_equals(c, child.parent)
Exemple #9
0
 def test_get_list_renders_correct_comments_including_tree_order(self):
     template_loader.templates['page/comment_list.html'] = ''
     a = create_comment(self.publishable, self.publishable.content_type)
     d = create_comment(self.publishable, self.publishable.content_type)
     ab = create_comment(self.publishable, self.publishable.content_type, parent_id=a.pk)
     de = create_comment(self.publishable, self.publishable.content_type, parent_id=d.pk)
     def_ = create_comment(self.publishable, self.publishable.content_type, parent_id=de.pk)
     ac = create_comment(self.publishable, self.publishable.content_type, parent_id=a.pk)
     response = self.client.get(self.get_url())
     self.assert_equals(200, response.status_code)
     self.assert_equals([a, ab, ac, d, de, def_], list(response.context['comment_list']))
Exemple #10
0
 def test_get_list_returns_first_page_with_no_params(self):
     template_loader.templates['page/comment_list.html'] = ''
     a = create_comment(self.publishable, self.publishable.content_type)
     d = create_comment(self.publishable, self.publishable.content_type)
     ab = create_comment(self.publishable, self.publishable.content_type, parent_id=a.pk)
     de = create_comment(self.publishable, self.publishable.content_type, parent_id=d.pk)
     def_ = create_comment(self.publishable, self.publishable.content_type, parent_id=de.pk)
     ac = create_comment(self.publishable, self.publishable.content_type, parent_id=a.pk)
     response = self.client.get(self.get_url())
     self.assert_equals(200, response.status_code)
     self.assert_equals([a, ab, ac], list(response.context['comment_list']))
Exemple #11
0
 def test_get_list_returns_second_page_if_asked_to(self):
     template_loader.templates['page/comment_list.html'] = ''
     a = create_comment(self.publishable, self.publishable.content_type)
     d = create_comment(self.publishable, self.publishable.content_type)
     ab = create_comment(self.publishable, self.publishable.content_type, parent_id=a.pk)
     de = create_comment(self.publishable, self.publishable.content_type, parent_id=d.pk)
     def_ = create_comment(self.publishable, self.publishable.content_type, parent_id=de.pk)
     ac = create_comment(self.publishable, self.publishable.content_type, parent_id=a.pk)
     response = self.client.get(self.get_url(), {'p': 2})
     self.assert_equals(200, response.status_code)
     self.assert_equals([d, de, def_], list(response.context['comment_list']))
Exemple #12
0
 def test_get_list_renders_only_given_branches_if_asked_to(self):
     template_loader.templates['page/comment_list.html'] = ''
     a = create_comment(self.publishable, self.publishable.content_type)
     d = create_comment(self.publishable, self.publishable.content_type)
     ab = create_comment(self.publishable, self.publishable.content_type, parent_id=a.pk)
     de = create_comment(self.publishable, self.publishable.content_type, parent_id=d.pk)
     def_ = create_comment(self.publishable, self.publishable.content_type, parent_id=de.pk)
     ac = create_comment(self.publishable, self.publishable.content_type, parent_id=a.pk)
     response = self.client.get(self.get_url()+ '?ids=%s&ids=%s' % (a.pk, d.pk))
     self.assert_equals(200, response.status_code)
     self.assert_equals([a, ab, ac, d, de, def_], list(response.context['comment_list']))
Exemple #13
0
 def test_get_list_renders_only_given_branch_if_asked_to(self):
     template_loader.templates['page/comment_list.html'] = ''
     a = create_comment(self.publishable, self.publishable.content_type)
     d = create_comment(self.publishable, self.publishable.content_type)
     ab = create_comment(self.publishable,
                         self.publishable.content_type,
                         parent_id=a.pk)
     de = create_comment(self.publishable,
                         self.publishable.content_type,
                         parent_id=d.pk)
     def_ = create_comment(self.publishable,
                           self.publishable.content_type,
                           parent_id=de.pk)
     ac = create_comment(self.publishable,
                         self.publishable.content_type,
                         parent_id=a.pk)
     response = self.client.get(self.get_url(), {'ids': a.pk})
     self.assert_equals(200, response.status_code)
     self.assert_equals([a, ab, ac], list(response.context['comment_list']))
Exemple #14
0
 def test_get_list_returns_first_page_with_no_params(self):
     template_loader.templates['page/comment_list.html'] = ''
     a = create_comment(self.publishable, self.publishable.content_type)
     d = create_comment(self.publishable, self.publishable.content_type)
     ab = create_comment(self.publishable,
                         self.publishable.content_type,
                         parent_id=a.pk)
     de = create_comment(self.publishable,
                         self.publishable.content_type,
                         parent_id=d.pk)
     def_ = create_comment(self.publishable,
                           self.publishable.content_type,
                           parent_id=de.pk)
     ac = create_comment(self.publishable,
                         self.publishable.content_type,
                         parent_id=a.pk)
     response = self.client.get(self.get_url())
     self.assert_equals(200, response.status_code)
     self.assert_equals([a, ab, ac], list(response.context['comment_list']))
Exemple #15
0
 def test_get_list_renders_correct_comments_including_tree_order(self):
     template_loader.templates['page/comment_list.html'] = ''
     a = create_comment(self.publishable, self.publishable.content_type)
     d = create_comment(self.publishable, self.publishable.content_type)
     ab = create_comment(self.publishable,
                         self.publishable.content_type,
                         parent_id=a.pk)
     de = create_comment(self.publishable,
                         self.publishable.content_type,
                         parent_id=d.pk)
     def_ = create_comment(self.publishable,
                           self.publishable.content_type,
                           parent_id=de.pk)
     ac = create_comment(self.publishable,
                         self.publishable.content_type,
                         parent_id=a.pk)
     response = self.client.get(self.get_url())
     self.assert_equals(200, response.status_code)
     self.assert_equals([a, ab, ac, d, de, def_],
                        list(response.context['comment_list']))
Exemple #16
0
 def test_get_list_returns_second_page_if_asked_to(self):
     template_loader.templates['page/comment_list.html'] = ''
     a = create_comment(self.publishable, self.publishable.content_type)
     d = create_comment(self.publishable, self.publishable.content_type)
     ab = create_comment(self.publishable,
                         self.publishable.content_type,
                         parent_id=a.pk)
     de = create_comment(self.publishable,
                         self.publishable.content_type,
                         parent_id=d.pk)
     def_ = create_comment(self.publishable,
                           self.publishable.content_type,
                           parent_id=de.pk)
     ac = create_comment(self.publishable,
                         self.publishable.content_type,
                         parent_id=a.pk)
     response = self.client.get(self.get_url(), {'p': 2})
     self.assert_equals(200, response.status_code)
     self.assert_equals([d, de, def_],
                        list(response.context['comment_list']))
Exemple #17
0
 def test_default_comment_options_for_article(self):
     create_comment(self.publishable, self.publishable.content_type)
     t = template.Template('''{% load ellacomments_tags %}{% get_comment_options for obj as opts %}{% if not opts.blocked %}XX{% endif %}''')
     self.assert_equals(u'XX', t.render(template.Context({'obj': self.only_publishable})))
Exemple #18
0
 def test_comment_list_for_article_is_picked_up_through_publishable(self):
     create_comment(self.publishable, self.publishable.content_type)
     t = template.Template('''{% load ellacomments_tags %}{% get_comment_list for obj as var_name%}{{ var_name|length }}''')
     self.assert_equals('1', t.render(template.Context({'obj': self.only_publishable})))