def _write(self, text, path): # pragma: no cover (integration test) """Write text to the object's file. :param text: text to write to a file :param path: path to the file """ if not self._exists: raise DoorstopError("cannot save to deleted: {}".format(self)) common.write_text(text, path)
def test_lines_html_document_without_child_links(self): """Verify HTML can be published from a document w/o child links.""" path = os.path.join(FILES, 'published2.html') expected = common.read_text(path) # Act lines = core.publisher.publish_lines(self.document, '.html') text = ''.join(line + '\n' for line in lines) # Assert if CHECK_PUBLISHED_CONTENT: self.assertEqual(expected, text) common.write_text(text, path)
def test_lines_markdown_document(self): """Verify Markdown can be published from a document.""" path = os.path.join(FILES, 'published.md') expected = common.read_text(path) # Act lines = core.publisher.publish_lines(self.document, '.md') text = ''.join(line + '\n' for line in lines) # Assert if CHECK_PUBLISHED_CONTENT: self.assertEqual(expected, text) common.write_text(text, path)
def test_lines_html_document_with_header(self): """Verify HTML can be published from a document with headers and child links contain header""" path = os.path.join(FILES_BETA, 'published3.html') expected = common.read_text(path) beta_features_tree = core.build(cwd=FILES_BETA, root=FILES_BETA) document_with_header = beta_features_tree.find_document('REQHEADER') # Act lines = core.publisher.publish_lines(document_with_header, '.html', linkify=True) text = ''.join(line + '\n' for line in lines) # Assert if CHECK_PUBLISHED_CONTENT: self.assertEqual(expected, text) common.write_text(text, path)
def tearDown(self): common.write_text(self.backup, self.path)
def bad_yaml_edit(path, **_): """Simulate adding invalid YAML to the index.""" common.write_text("%bad", path)