Example #1
0
 def test_malformed_document_with_frontmatter(self):
     source = inspect.cleandoc("""%YAML 1.1
     ---
     title: A Fake Title
     """)
     with tempfile.NamedTemporaryFile(delete=False) as f:
         f.write(source.encode('utf-8'))
     mixin = FrontmatterComposerMixin()
     with self.assertRaises(AbortError):
         mixin.get_data(f.name)
Example #2
0
 def test_malformed_document_with_frontmatter(self):
     source = inspect.cleandoc("""%YAML 1.1
     ---
     title: A Fake Title
     """)
     with tempfile.NamedTemporaryFile(delete=False) as f:
         f.write(source.encode('utf-8'))
     mixin = FrontmatterComposerMixin()
     with self.assertRaises(AbortError):
         mixin.get_data(f.name)
Example #3
0
 def test_gets_frontmatter_no_directive(self):
     source = inspect.cleandoc("""---
     title: A Fake Title
     ---
     The Content
     """)
     with tempfile.NamedTemporaryFile(delete=False) as f:
         f.write(source.encode('utf-8'))
     mixin = FrontmatterComposerMixin()
     data, source = mixin.get_data(f.name)
     self.assertEqual('A Fake Title', data['title'])
     self.assertEqual('The Content', source)
Example #4
0
 def test_gets_frontmatter_no_directive(self):
     source = inspect.cleandoc("""---
     title: A Fake Title
     ---
     The Content
     """)
     with tempfile.NamedTemporaryFile(delete=False) as f:
         f.write(source.encode('utf-8'))
     mixin = FrontmatterComposerMixin()
     data, source = mixin.get_data(f.name)
     self.assertEqual('A Fake Title', data['title'])
     self.assertEqual('The Content', source)
Example #5
0
 def test_fires_frontmatter_loaded(self, signals):
     source = inspect.cleandoc("""%YAML 1.1
     ---
     title: A Fake Title
     ---
     The Content
     """)
     with tempfile.NamedTemporaryFile(delete=False) as f:
         f.write(source.encode('utf-8'))
     mixin = FrontmatterComposerMixin()
     data, source = mixin.get_data(f.name)
     signals.frontmatter_loaded.send.assert_called_once_with(
         f.name, frontmatter={'title': 'A Fake Title'})
Example #6
0
 def test_fires_frontmatter_loaded(self, signals):
     source = inspect.cleandoc("""%YAML 1.1
     ---
     title: A Fake Title
     ---
     The Content
     """)
     with tempfile.NamedTemporaryFile(delete=False) as f:
         f.write(source.encode('utf-8'))
     mixin = FrontmatterComposerMixin()
     data, source = mixin.get_data(f.name)
     signals.frontmatter_loaded.send.assert_called_once_with(
         f.name, frontmatter={'title': 'A Fake Title'})
Example #7
0
 def test_gets_frontmatter(self):
     source = inspect.cleandoc("""%YAML 1.1
     ---
     title: "ØMQ: A dynamic book with surprises"
     ---
     The Content
     """)
     with tempfile.NamedTemporaryFile(delete=False) as f:
         f.write(source.encode('utf-8'))
     mixin = FrontmatterComposerMixin()
     data, source = mixin.get_data(f.name)
     self.assertEqual('ØMQ: A dynamic book with surprises', data['title'])
     self.assertEqual('The Content', source)
Example #8
0
 def test_looks_like_frontmatter(self):
     mixin = FrontmatterComposerMixin()
     self.assertTrue(mixin._has_frontmatter('%YAML 1.1'))
     self.assertTrue(mixin._has_frontmatter('---'))
Example #9
0
 def test_looks_like_frontmatter(self):
     mixin = FrontmatterComposerMixin()
     self.assertTrue(mixin._has_frontmatter('%YAML 1.1'))
     self.assertTrue(mixin._has_frontmatter('---'))