Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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'})
Esempio n. 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'})
Esempio n. 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)