Пример #1
0
 def test_cssclass_failure(self):
     """
     Test cssclass option with no arguments. Should complain with system
     message.
     """
     html_out, _ = blogArticleString(CSSCLASS1)
     self.assertTrue('System Message: ERROR/3' in html_out)
Пример #2
0
 def test_cssclass_correct(self):
     """
     Test cssclass option with Dessert256 as an argument. Should be used as
     a main div CSS class.
     """
     html_out, _ = blogArticleString(CSSCLASS2)
     self.assertTrue('<div class="Dessert256">' in html_out)
Пример #3
0
 def test_linenos_with_arg3(self):
     """
     Test linenos option with correct argument type and correct value.
     Should count from 1 in this case.
     """
     html_out, _ = blogArticleString(LINENOS4)
     self.assertTrue('<pre><span class="lineno">12</span>' in html_out)
Пример #4
0
 def test_cssclass_failure(self):
     """
     Test cssclass option with no arguments. Should complain with system
     message.
     """
     html_out, _ = blogArticleString(CSSCLASS1)
     self.assertTrue('System Message: ERROR/3' in html_out)
Пример #5
0
 def test_cssclass_correct(self):
     """
     Test cssclass option with Dessert256 as an argument. Should be used as
     a main div CSS class.
     """
     html_out, _ = blogArticleString(CSSCLASS2)
     self.assertTrue('<div class="Dessert256">' in html_out)
Пример #6
0
 def test_linenos_with_arg3(self):
     """
     Test linenos option with correct argument type and correct value.
     Should count from 1 in this case.
     """
     html_out, _ = blogArticleString(LINENOS4)
     self.assertTrue('<pre><span class="lineno">12</span>' in html_out)
Пример #7
0
    def test_blogArticleString(self):
        html_out, attrs = blogArticleString(REST_ARTICLE)
        self.assertEqual(len(attrs), 3)
        self.assertTrue(len(html_out) > 0)
        self.assertTrue("<html" not in html_out)
        self.assertTrue("</html>" not in html_out)
        self.assertTrue(
            "<?xml version=\"1.0\" encoding=\"utf-8\"" not in html_out)
        self.assertTrue("\n\n<!-- more -->\n\n" in html_out)
        self.assertTrue(
            "<title>Title — This is a test</title>" not in html_out)
        self.assertTrue('type="text/css"' not in html_out)
        self.assertTrue(re.search(r"<h4>Section 1</h4>", html_out))
        self.assertTrue(re.search(r"<h5>Subsection 1.1</h5>", html_out))
        self.assertTrue("description" not in html_out)

        self.assertEqual(attrs['title'], u"Title — This is a test")
        self.assertEqual(attrs['date'], "2010-12-12T12:36:36+01:00")
        self.assertEqual(attrs['tags'], "this is a test, Blogger, rest")
Пример #8
0
    def test_blogArticleString(self):
        html_out, attrs = blogArticleString(REST_ARTICLE)
        self.assertEqual(len(attrs), 3)
        self.assertTrue(len(html_out) > 0)
        self.assertTrue("<html" not in html_out)
        self.assertTrue("</html>" not in html_out)
        self.assertTrue("<?xml version=\"1.0\" encoding=\"utf-8\"" not in
                        html_out)
        self.assertTrue("\n\n<!-- more -->\n\n" in html_out)
        self.assertTrue("<title>Title — This is a test</title>" not in
                        html_out)
        self.assertTrue('type="text/css"' not in html_out)
        self.assertTrue(re.search(r"<h4>Section 1</h4>", html_out))
        self.assertTrue(re.search(r"<h5>Subsection 1.1</h5>", html_out))
        self.assertTrue("description" not in html_out)

        self.assertEqual(attrs['title'], u"Title — This is a test")
        self.assertEqual(attrs['date'], "2010-12-12T12:36:36+01:00")
        self.assertEqual(attrs['tags'], "this is a test, Blogger, rest")
Пример #9
0
    def post(self):
        """
        Do post article
        """
        bufcontent = "\n".join(self.buff)
        html, attrs = blogArticleString(bufcontent)

        parse_msg = self._check_html(html, True)
        if parse_msg:
            self._open_qf(parse_msg)
            return "There are errors in generated document"

        if not self.password:
            self.password = \
                    vim.eval('inputsecret("Enter your gmail password: "******"Article '%s' has been updated" % post.title.text)
            msg = msg.encode(self.vim_encoding)
        else:
            post = blog.create_article(html, attrs=attrs)
            msg = "New article with id %s has been created" % \
                    post.get_post_id()

        for item, value in (('id', post.get_post_id()),
                            ('date', post.published.text),
                            ('title', post.title.text),
                            ('modified', post.updated.text),
                            ('tags',
                             ", ".join([cat.term for cat in post.category]))):
            self._update_docinfo(item, value)
        return msg
Пример #10
0
 def test_linenos_with_wrong_arg(self):
     """
     Test linenos option with wrong argument type. Should count from 1.
     """
     html_out, _ = blogArticleString(LINENOS5)
     self.assertTrue('<pre><span class="lineno">1</span>' in html_out)
Пример #11
0
 def test_linenos_no_args(self):
     """
     Test linenos option with no additional arguments
     """
     html_out, _ = blogArticleString(LINENOS1)
     self.assertTrue('<pre><span class="lineno">1</span>' in html_out)
Пример #12
0
 def test_linenos_with_wrong_arg(self):
     """
     Test linenos option with wrong argument type. Should count from 1.
     """
     html_out, _ = blogArticleString(LINENOS5)
     self.assertTrue('<pre><span class="lineno">1</span>' in html_out)
Пример #13
0
 def test_linenos_no_args(self):
     """
     Test linenos option with no additional arguments
     """
     html_out, _ = blogArticleString(LINENOS1)
     self.assertTrue('<pre><span class="lineno">1</span>' in html_out)