コード例 #1
0
    def test_bad_format(self):
        """Tests case for badly formatted raw content."""
        doc = self.pod.get_doc('/content/pages/html.html')
        content = 'testing: > 2'

        with self.assertRaises(document_front_matter.BadFormatError):
            document_front_matter.DocumentFrontMatter(doc,
                                                      raw_front_matter=content)

        doc = self.pod.get_doc('/content/pages/html.html')
        content = textwrap.dedent("""
            name: Jane Doe
            ---
            foo: bar
            """).lstrip()
        with self.assertRaises(document_front_matter.BadFormatError):
            document_front_matter.DocumentFrontMatter(doc,
                                                      raw_front_matter=content)

        doc = self.pod.get_doc('/content/pages/html.html')
        content = textwrap.dedent("""
            - alpha
            - beta
            - charlie
            """).lstrip()
        with self.assertRaises(document_front_matter.BadFormatError):
            document_front_matter.DocumentFrontMatter(doc,
                                                      raw_front_matter=content)
コード例 #2
0
ファイル: document_format.py プロジェクト: uxder/grow
    def front_matter(self):
        cached_front_matter = self._doc.pod.podcache.document_cache\
            .get_property(self._doc, 'front_matter')
        if cached_front_matter:
            return doc_front_matter.DocumentFrontMatter(
                self._doc, raw_front_matter=cached_front_matter)

        front_matter = self._parse_front_matter()
        self._doc.pod.podcache.document_cache.add_property(
            self._doc, 'front_matter', front_matter.export())
        return front_matter
コード例 #3
0
    def test_export(self):
        """Test exporting the front raw matter."""
        expected = textwrap.dedent("""
            $title@: HTML Page
            $hidden: true
            """).strip()
        doc = self.pod.get_doc('/content/pages/html.html')

        self.assertEquals(
            expected,
            document_front_matter.DocumentFrontMatter(doc).export())
コード例 #4
0
ファイル: document_format.py プロジェクト: uxder/grow
 def _parse_front_matter(self):
     """Parse the front matter from the raw content."""
     return doc_front_matter.DocumentFrontMatter(self._doc)
コード例 #5
0
ファイル: document_format.py プロジェクト: uxder/grow
 def _parse_front_matter(self):
     return doc_front_matter.DocumentFrontMatter(
         self._doc, raw_front_matter=self.raw_content)
コード例 #6
0
    def test_empty_raw_front_matter(self):
        """Test for empty or missing front matter."""
        doc = self.pod.get_doc('/content/pages/html.html')

        document_front_matter.DocumentFrontMatter(doc, raw_front_matter=None)