MCPcopy
hub / github.com/liangliangyy/DjangoBlog / test_validate_comment

Method test_validate_comment

comments/tests.py:33–109  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

31 comment.save()
32
33 def test_validate_comment(self):
34 self.client.login(username='liangliangyy1', password='liangliangyy1')
35
36 category = Category()
37 category.name = "categoryccc"
38 category.save()
39
40 article = Article()
41 article.title = "nicetitleccc"
42 article.body = "nicecontentccc"
43 article.author = self.user
44 article.category = category
45 article.type = 'a'
46 article.status = 'p'
47 article.save()
48
49 comment_url = reverse(
50 'comments:postcomment', kwargs={
51 'article_id': article.id})
52
53 response = self.client.post(comment_url,
54 {
55 'body': '123ffffffffff'
56 })
57
58 self.assertEqual(response.status_code, 302)
59
60 article = Article.objects.get(pk=article.pk)
61 self.assertEqual(len(article.comment_list()), 0)
62 self.update_article_comment_status(article)
63
64 self.assertEqual(len(article.comment_list()), 1)
65
66 response = self.client.post(comment_url,
67 {
68 'body': '123ffffffffff',
69 })
70
71 self.assertEqual(response.status_code, 302)
72
73 article = Article.objects.get(pk=article.pk)
74 self.update_article_comment_status(article)
75 self.assertEqual(len(article.comment_list()), 2)
76 parent_comment_id = article.comment_list()[0].id
77
78 response = self.client.post(comment_url,
79 {
80 'body': '''
81 # Title1
82
83 ```python
84 import os
85 ```
86
87 [url](https://www.lylinux.net/)
88
89 [ddd](http://www.baidu.com)
90

Callers

nothing calls this directly

Calls 11

saveMethod · 0.95
comment_listMethod · 0.95
CategoryClass · 0.90
ArticleClass · 0.90
send_comment_emailFunction · 0.90
parse_commenttreeFunction · 0.85
show_comment_itemFunction · 0.85
postMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected