def test_load_save(self): """Verify text formatting is preserved.""" item = Item(self.ITEM) item.load() item.save() text = common.read_text(self.ITEM) self.assertEqual(self.backup, text)
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_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 _reorder_from_index(document, path): """Reorder a document's item from the index.""" # Load and parse index text = common.read_text(path) data = common.load_yaml(text, path) # Read updated values initial = data.get('initial', 1.0) outline = data.get('outline', []) # Update levels level = Level(initial) Document._reorder_section(outline, level, document)
def _read(self, path): # pragma: no cover (integration test) """Read text from the object's file. :param path: path to a text file :return: contexts of text file """ if not self._exists: msg = "cannot read from deleted: {}".format(self.path) raise DoorstopError(msg) return common.read_text(path)
def test_import_file_with_map(self): """Verify 'doorstop import' can import a file using a custom map.""" path = os.path.join(FILES, "exported-map.csv") dirpath = os.path.join(self.temp, "imported", "prefix") main(["create", "PREFIX", dirpath]) # Act self.assertIs(None, main(["import", path, "PREFIX", "--map", "{'mylevel': 'level'}"])) # Assert path = os.path.join(dirpath, "REQ001.yml") self.assertTrue(os.path.isfile(path)) text = common.read_text(path) self.assertIn("\nlevel: 1.2.3", text)
def test_import_file_with_map(self): """Verify 'doorstop import' can import a file using a custom map.""" path = os.path.join(FILES, 'exported-map.csv') dirpath = os.path.join(self.temp, 'imported', 'prefix') main(['create', 'PREFIX', dirpath]) # Act self.assertIs(None, main(['import', path, 'PREFIX', '--map', "{'mylevel': 'level'}"])) # Assert path = os.path.join(dirpath, 'REQ001.yml') self.assertTrue(os.path.isfile(path)) text = common.read_text(path) self.assertIn('\nlevel: 1.2.3', text)
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 _file_yml(path, document, **_): """Import items from a YAML export to a document. :param path: input file location :param document: document to import items """ # Parse the file log.info("reading items in {}...".format(path)) text = common.read_text(path) # Load the YAML data data = common.load_yaml(text, path) # Add items for uid, attrs in data.items(): try: item = document.find_item(uid) except DoorstopError: pass # no matching item else: item.delete() add_item(document.prefix, uid, attrs=attrs, document=document)
def setUp(self): self.backup = common.read_text(self.ITEM) main(['link', 'tut3', 'req2']) # create a temporary link
def setUp(self): self.backup = common.read_text(self.ITEM) with patch("doorstop.settings.ADDREMOVE_FILES", False): main(["link", "tut3", "req2"]) # create a temporary link
def setUp(self): self.path = os.path.join(FILES, 'REQ001.yml') self.backup = common.read_text(self.path) self.item = core.Item(self.path) self.item.tree = Mock() self.item.tree.vcs = mockvcs.WorkingCopy(EMPTY)
def setUp(self): self.path = os.path.join(FILES, 'REQ001.yml') self.backup = common.read_text(self.path) self.item = core.Item(self.path) self.tree = core.Tree(core.Document(SYS)) self.tree._place(core.Document(FILES)) # pylint: disable=W0212
def read_yml(path): """Return a dictionary of items from a YAML file.""" text = common.read_text(path) data = yaml.load(text) return data
def setUp(self): self.backup = common.read_text(self.ITEM) with patch('doorstop.settings.ADDREMOVE_FILES', False): main(['link', 'tut3', 'req2']) # create a temporary link
def setUp(self): self.path = os.path.join(FILES, 'REQ001.yml') self.backup = common.read_text(self.path) self.item = core.Item(self.path) self.tree = core.Tree(core.Document(SYS)) self.tree._place(core.Document(FILES))
def setUp(self): self.backup = common.read_text(self.ITEM)
def setUp(self): self.path = os.path.join(FILES, 'REQ001.yml') self.backup = common.read_text(self.path) self.item = core.Item(self.path)