def comment( self, title="title", author="author", body="body", url=None, email=None, ipaddress=None, encoding=None, preview=None, **kwargs ): """Posts a comment with the given contents.""" # set the encoding in the config. it should default to utf-8 if encoding: self.config["blog_encoding"] = encoding # build up the form data and post the comment args = [ (arg, vars()[arg]) for arg in ("title", "author", "body", "url", "email", "preview") if vars()[arg] is not None ] self.set_form_data(dict(args)) comments.cb_prepare(self.args)
def test_cb_prepare_showcomments(self): """cb_prepare() should set display_comment_default to show comments.""" # default is to not show comments del self.data['bl_type'] comments.cb_prepare(self.args) self.assertEquals(False, self.data['display_comment_default']) # show them if the bl_type config var is 'file' self.data['bl_type'] = 'db' comments.cb_prepare(self.args) self.assertEquals(False, self.data['display_comment_default']) self.data['bl_type'] = 'file' comments.cb_prepare(self.args) self.assertEquals(True, self.data['display_comment_default']) # or if the query string has showcomments=yes del self.data['bl_type'] self.request.add_http({'QUERY_STRING': 'x=yes&showcomments=no7&y=no'}) comments.cb_prepare(self.args) self.assertEquals(False, self.data['display_comment_default']) self.request.add_http({'QUERY_STRING': 'x=yes&showcomments=yes&y=no'}) comments.cb_prepare(self.args) self.assertEquals(True, self.data['display_comment_default'])
def test_cb_prepare_showcomments(self): """cb_prepare() should set display_comment_default to show comments.""" # default is to not show comments del self.data["bl_type"] comments.cb_prepare(self.args) self.assertEquals(False, self.data["display_comment_default"]) # show them if the bl_type config var is 'file' self.data["bl_type"] = "db" comments.cb_prepare(self.args) self.assertEquals(False, self.data["display_comment_default"]) self.data["bl_type"] = "file" comments.cb_prepare(self.args) self.assertEquals(True, self.data["display_comment_default"]) # or if the query string has showcomments=yes del self.data["bl_type"] self.request.add_http({"QUERY_STRING": "x=yes&showcomments=no7&y=no"}) comments.cb_prepare(self.args) self.assertEquals(False, self.data["display_comment_default"]) self.request.add_http({"QUERY_STRING": "x=yes&showcomments=yes&y=no"}) comments.cb_prepare(self.args) self.assertEquals(True, self.data["display_comment_default"])
def comment(self, title='title', author='author', body='body', url=None, email=None, ipaddress=None, encoding=None, preview=None, **kwargs): """Posts a comment with the given contents.""" # set the encoding in the config. it should default to utf-8 if encoding: self.config['blog_encoding'] = encoding # build up the form data and post the comment args = [(arg, vars()[arg]) for arg in ('title', 'author', 'body', 'url', 'email', 'preview') if vars()[arg] is not None] self.set_form_data(dict(args)) comments.cb_prepare(self.args)