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

Method create_article

djangoblog/test_base.py:72–88  ·  view source on GitHub ↗

创建文章

(self, title='测试文章', body='测试内容', author=None,
                      category=None, status='p', article_type='a')

Source from the content-addressed store, hash-verified

70 return tag
71
72 def create_article(self, title='测试文章', body='测试内容', author=None,
73 category=None, status='p', article_type='a'):
74 """创建文章"""
75 if author is None:
76 author = self.user if hasattr(self, 'user') else self.create_user()
77 if category is None:
78 category = self.category if hasattr(self, 'category') else self.create_category()
79
80 article = Article.objects.create(
81 title=title,
82 body=body,
83 author=author,
84 category=category,
85 type=article_type,
86 status=status
87 )
88 return article
89
90 def create_comment(self, article=None, author=None, body='测试评论', parent=None):
91 """创建评论"""

Calls 3

create_userMethod · 0.95
create_categoryMethod · 0.95
createMethod · 0.80

Tested by

no test coverage detected