Example #1
0
 def test_import_xlsx_to_document_existing(self):
     """Verify 'doorstop import' can import XLSX to an existing document."""
     path = os.path.join(FILES, 'exported.xlsx')
     dirpath = os.path.join(self.temp, 'imported', 'prefix')
     main(['create', 'PREFIX', dirpath])
     # Act
     self.assertIs(None, main(['import', path, 'PREFIX']))
     # Assert
     path = os.path.join(dirpath, 'REQ001.yml')
     self.assertTrue(os.path.isfile(path))
Example #2
0
 def test_import_xlsx_to_document_existing(self):
     """Verify 'doorstop import' can import XLSX to an existing document."""
     path = os.path.join(FILES, 'exported.xlsx')
     dirpath = os.path.join(self.temp, 'imported', 'prefix')
     main(['create', 'PREFIX', dirpath])
     # Act
     self.assertIs(None, main(['import', path, 'PREFIX']))
     # Assert
     path = os.path.join(dirpath, 'REQ001.yml')
     self.assertTrue(os.path.isfile(path))
Example #3
0
 def test_import_xlsx_to_document_existing(self):
     """Verify 'doorstop import' can import XLSX to an existing document."""
     path = os.path.join(FILES, "exported.xlsx")
     dirpath = os.path.join(self.temp, "imported", "prefix")
     main(["create", "PREFIX", dirpath])
     # Act
     self.assertIs(None, main(["import", path, "PREFIX"]))
     # Assert
     path = os.path.join(dirpath, "REQ001.yml")
     self.assertTrue(os.path.isfile(path))
Example #4
0
 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)
Example #5
0
 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)
Example #6
0
 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_options(self):
     """Verify 'doorstop' can be run with options."""
     self.assertIs(
         None,
         main.main([
             '--no-reformat',
             '--no-ref-check',
             '--no-child-check',
             '--reorder',
             '--no-level-check',
             '--no-suspect-check',
             '--no-review-check',
             '--no-cache',
             '--warn-all',
             '--error-all',
         ]),
     )
     self.assertFalse(settings.REFORMAT)
     self.assertFalse(settings.CHECK_REF)
     self.assertFalse(settings.CHECK_CHILD_LINKS)
     self.assertTrue(settings.REORDER)
     self.assertFalse(settings.CHECK_LEVELS)
     self.assertFalse(settings.CHECK_SUSPECT_LINKS)
     self.assertFalse(settings.CHECK_REVIEW_STATUS)
     self.assertFalse(settings.CACHE_DOCUMENTS)
     self.assertFalse(settings.CACHE_ITEMS)
     self.assertFalse(settings.CACHE_PATHS)
     self.assertTrue(settings.WARN_ALL)
     self.assertTrue(settings.ERROR_ALL)
Example #8
0
 def test_edit_document_no_no(self, mock_launch):
     """Verify 'doorstop edit' can be called with a document (no, no)."""
     path = "TUT-456.yml"
     self.assertIs(None, main(['edit', 'tut', '-T', 'my_editor']))
     common.delete(path)
     mock_launch.assert_called_once_with(os.path.normpath(path),
                                         tool='my_editor')
Example #9
0
 def test_reorder_document_manual(self, mock_launch, mock_reorder_auto):
     """Verify 'doorstop reorder' can be called with a document (manual)."""
     self.assertIs(None, main(['reorder', self.prefix, '--manual']))
     mock_launch.assert_called_once_with(self.path,
                                         tool=os.getenv('EDITOR'))
     self.assertEqual(0, mock_reorder_auto.call_count)
     self.assertFalse(os.path.exists(self.path))
Example #10
0
 def test_empty(self):
     """Verify 'doorstop' can be run in a working copy with no docs."""
     os.mkdir(os.path.join(self.temp, '.mockvcs'))
     os.chdir(self.temp)
     self.assertIs(None, main([]))
     self.assertTrue(settings.REFORMAT)
     self.assertTrue(settings.CHECK_REF)
     self.assertTrue(settings.CHECK_RLINKS)
Example #11
0
 def test_publish_document_template(self, mock_publish):
     """Verify 'doorstop publish' is called with template."""
     path = os.path.join(self.temp, 'req.html')
     self.assertIs(None, main(['publish', '--template',
                               'my_template.html', 'req', path]))
     mock_publish.assert_called_once_with(Document(os.path.abspath(REQS)),
                                          path, '.html',
                                          template='my_template.html')
Example #12
0
 def test_import_item_with_attrs(self):
     """Verify 'doorstop import' can import an item with attributes."""
     self.assertIs(
         None,
         main([
             'import', '--item', 'REQ', 'REQ099', '--attrs',
             "{'text': 'The item text.'}"
         ]))
Example #13
0
 def test_publish_document_template(self, mock_publish):
     """Verify 'doorstop publish' is called with template."""
     path = os.path.join(self.temp, 'req.html')
     self.assertIs(
         None, main(['publish', '--template', 'my_template.html', 'req', path])
     )
     mock_publish.assert_called_once_with(
         Document(os.path.abspath(REQS)), path, '.html', template='my_template.html'
     )
Example #14
0
 def test_options(self):
     """Verify 'doorstop' can be run with options."""
     os.mkdir(os.path.join(self.temp, '.mockvcs'))
     os.chdir(self.temp)
     self.assertIs(None, main(['--no-reformat',
                               '--no-ref-check',
                               '--no-rlinks-check']))
     self.assertFalse(settings.REFORMAT)
     self.assertFalse(settings.CHECK_REF)
     self.assertFalse(settings.CHECK_RLINKS)
Example #15
0
 def test_add_multiple(self):
     """Verify 'doorstop add' can be called with a given positive count"""
     number = get_next_number()
     numbers = (number, number + 1, number + 2)
     self.assertIs(None, main(['add', 'TUT', '--count', '3']))
     filenames = ("TUT{}.yml".format(str(x).zfill(3)) for x in numbers)
     paths = [os.path.join(TUTORIAL, f) for f in filenames]
     self.assertTrue(os.path.isfile(paths[0]))
     self.assertTrue(os.path.isfile(paths[1]))
     self.assertTrue(os.path.isfile(paths[2]))
     os.remove(paths[1])
     os.remove(paths[2])
Example #16
0
 def test_add_multiple(self):
     """Verify 'doorstop add' can be called with a given positive count"""
     number = get_next_number()
     numbers = (number, number + 1, number + 2)
     self.assertIs(None, main(['add', 'TUT', '--count', '3']))
     filenames = ("TUT{}.yml".format(str(x).zfill(3)) for x in numbers)
     paths = [os.path.join(TUTORIAL, f) for f in filenames]
     self.assertTrue(os.path.isfile(paths[0]))
     self.assertTrue(os.path.isfile(paths[1]))
     self.assertTrue(os.path.isfile(paths[2]))
     os.remove(paths[1])
     os.remove(paths[2])
Example #17
0
 def test_empty(self):
     """Verify 'doorstop' can be run in a working copy with no docs."""
     os.mkdir(os.path.join(self.temp, '.mockvcs'))
     os.chdir(self.temp)
     self.assertIs(None, main([]))
     self.assertTrue(settings.REFORMAT)
     self.assertTrue(settings.CHECK_REF)
     self.assertTrue(settings.CHECK_CHILD_LINKS)
     self.assertFalse(settings.REORDER)
     self.assertTrue(settings.CHECK_LEVELS)
     self.assertTrue(settings.CHECK_SUSPECT_LINKS)
     self.assertTrue(settings.CHECK_REVIEW_STATUS)
Example #18
0
 def test_empty(self):
     """Verify 'doorstop' can be run in a working copy with no docs."""
     os.mkdir(os.path.join(self.temp, '.mockvcs'))
     os.chdir(self.temp)
     self.assertIs(None, main([]))
     self.assertTrue(settings.REFORMAT)
     self.assertTrue(settings.CHECK_REF)
     self.assertTrue(settings.CHECK_CHILD_LINKS)
     self.assertFalse(settings.REORDER)
     self.assertTrue(settings.CHECK_LEVELS)
     self.assertTrue(settings.CHECK_SUSPECT_LINKS)
     self.assertTrue(settings.CHECK_REVIEW_STATUS)
Example #19
0
 def test_empty(self):
     """Verify 'doorstop' can be run in a working copy with no docs."""
     self.assertIs(None, main.main([]))
     self.assertTrue(settings.REFORMAT)
     self.assertTrue(settings.CHECK_REF)
     self.assertTrue(settings.CHECK_CHILD_LINKS)
     self.assertFalse(settings.REORDER)
     self.assertTrue(settings.CHECK_LEVELS)
     self.assertTrue(settings.CHECK_SUSPECT_LINKS)
     self.assertTrue(settings.CHECK_REVIEW_STATUS)
     self.assertTrue(settings.CACHE_DOCUMENTS)
     self.assertTrue(settings.CACHE_ITEMS)
     self.assertTrue(settings.CACHE_PATHS)
     self.assertFalse(settings.WARN_ALL)
     self.assertFalse(settings.ERROR_ALL)
Example #20
0
 def test_options(self):
     """Verify 'doorstop' can be run with options."""
     os.mkdir(os.path.join(self.temp, '.mockvcs'))
     os.chdir(self.temp)
     self.assertIs(None, main(['--no-reformat',
                               '--no-ref-check',
                               '--no-child-check',
                               '--reorder',
                               '--no-level-check',
                               '--no-suspect-check',
                               '--no-review-check']))
     self.assertFalse(settings.REFORMAT)
     self.assertFalse(settings.CHECK_REF)
     self.assertFalse(settings.CHECK_CHILD_LINKS)
     self.assertTrue(settings.REORDER)
     self.assertFalse(settings.CHECK_LEVELS)
     self.assertFalse(settings.CHECK_SUSPECT_LINKS)
     self.assertFalse(settings.CHECK_REVIEW_STATUS)
Example #21
0
 def test_options(self):
     """Verify 'doorstop' can be run with options."""
     os.mkdir(os.path.join(self.temp, '.mockvcs'))
     os.chdir(self.temp)
     self.assertIs(
         None,
         main([
             '--no-reformat', '--no-ref-check', '--no-child-check',
             '--reorder', '--no-level-check', '--no-suspect-check',
             '--no-review-check'
         ]))
     self.assertFalse(settings.REFORMAT)
     self.assertFalse(settings.CHECK_REF)
     self.assertFalse(settings.CHECK_CHILD_LINKS)
     self.assertTrue(settings.REORDER)
     self.assertFalse(settings.CHECK_LEVELS)
     self.assertFalse(settings.CHECK_SUSPECT_LINKS)
     self.assertFalse(settings.CHECK_REVIEW_STATUS)
Example #22
0
 def test_options(self):
     """Verify 'doorstop' can be run with options."""
     self.assertIs(None, main.main(['--no-reformat',
                                    '--no-ref-check',
                                    '--no-child-check',
                                    '--reorder',
                                    '--no-level-check',
                                    '--no-suspect-check',
                                    '--no-review-check',
                                    '--no-cache',
                                    '--warn-all',
                                    '--error-all']))
     self.assertFalse(settings.REFORMAT)
     self.assertFalse(settings.CHECK_REF)
     self.assertFalse(settings.CHECK_CHILD_LINKS)
     self.assertTrue(settings.REORDER)
     self.assertFalse(settings.CHECK_LEVELS)
     self.assertFalse(settings.CHECK_SUSPECT_LINKS)
     self.assertFalse(settings.CHECK_REVIEW_STATUS)
     self.assertFalse(settings.CACHE_DOCUMENTS)
     self.assertFalse(settings.CACHE_ITEMS)
     self.assertFalse(settings.CACHE_PATHS)
     self.assertTrue(settings.WARN_ALL)
     self.assertTrue(settings.ERROR_ALL)
Example #23
0
 def test_publish_document_html(self):
     """Verify 'doorstop publish' can create HTML output."""
     self.assertIs(None, main(['publish', 'hlt', '--html']))
Example #24
0
 def test_publish_document_text(self):
     """Verify 'doorstop publish' can create text output."""
     self.assertIs(None, main(['publish', 'tut', '--width', '75']))
Example #25
0
 def test_publish_document_without_child_links(self):
     """Verify 'doorstop publish' can create output without child links."""
     self.assertIs(None, main(['publish', 'tut', '--no-child-links']))
     self.assertFalse(settings.PUBLISH_CHILD_LINKS)
Example #26
0
 def test_export_document_xlsx(self):
     """Verify 'doorstop export' can create an XLSX file."""
     path = os.path.join(self.temp, 'tut.xlsx')
     self.assertIs(None, main(['export', 'tut', path]))
     self.assertTrue(os.path.isfile(path))
Example #27
0
 def test_export_document_xlsx(self):
     """Verify 'doorstop export' can create an XLSX file."""
     path = os.path.join(self.temp, 'tut.xlsx')
     self.assertIs(None, main(['export', 'tut', path]))
     self.assertTrue(os.path.isfile(path))
Example #28
0
 def test_main_custom_root(self):
     """Verify 'doorstop' can be provided a custom root path."""
     os.chdir(self.temp)
     self.assertIs(None, main(['--project', '.']))
Example #29
0
 def test_verbose_quiet(self):
     """Verify verbose level -1 can be set."""
     self.assertIs(None, main(['-q']))
     self.assertEqual(-1, common.verbosity)
Example #30
0
 def test_publish_document_markdown(self):
     """Verify 'doorstop publish' can create Markdown output."""
     self.assertIs(None, main(['publish', 'req', '--markdown']))
Example #31
0
 def test_verbose_quiet(self):
     """Verify verbose level -1 can be set."""
     self.assertIs(None, main(['-q']))
     self.assertEqual(-1, common.verbosity)
Example #32
0
 def test_verbose_5(self):
     """Verify verbose level 5 cannot be set."""
     self.assertIs(None, main(['-vvvvv']))
     self.assertEqual(4, common.verbosity)
Example #33
0
 def test_verbose_4(self):
     """Verify verbose level 4 can be set."""
     self.assertIs(None, main(['-vvvv']))
Example #34
0
 def test_create(self):
     """Verify 'doorstop create' can be called."""
     self.assertIs(None, main(['create', '_TEMP', self.temp, '-p', 'REQ']))
Example #35
0
 def test_verbose_0(self):
     """Verify verbose level 0 can be set."""
     self.assertIs(None, main([]))
Example #36
0
 def test_publish_tree_text(self):
     """Verify 'doorstop publish' can create a text directory."""
     path = os.path.join(self.temp, 'all')
     self.assertIs(None, main(['publish', 'all', path, '--text']))
     self.assertTrue(os.path.isdir(path))
     self.assertFalse(os.path.isfile(os.path.join(path, 'index.html')))
Example #37
0
 def test_publish_tree_text(self):
     """Verify 'doorstop publish' can create a text directory."""
     path = os.path.join(self.temp, 'all')
     self.assertIs(None, main(['publish', 'all', path, '--text']))
     self.assertTrue(os.path.isdir(path))
     self.assertFalse(os.path.isfile(os.path.join(path, 'index.html')))
Example #38
0
 def test_verbose_4(self):
     """Verify verbose level 4 can be set."""
     self.assertIs(None, main(['-vvvv']))
Example #39
0
 def test_publish_document_text(self):
     """Verify 'doorstop publish' can create text output."""
     self.assertIs(None, main(['publish', 'tut', '--width', '75']))
Example #40
0
 def test_publish_document_html_file(self):
     """Verify 'doorstop publish' can create an HTML file."""
     path = os.path.join(self.temp, 'req.html')
     self.assertIs(None, main(['publish', 'req', path]))
     self.assertTrue(os.path.isfile(path))
Example #41
0
 def test_publish_document_without_body_levels(self):
     """Verify 'doorstop publish' can create output without body levels."""
     self.assertIs(None, main(['publish', 'tut', '--no-body-levels']))
     self.assertFalse(settings.PUBLISH_BODY_LEVELS)
Example #42
0
 def test_export_document_stdout_width(self):
     """Verify 'doorstop export' can create output."""
     self.assertIs(None, main(['export', 'tut', '--width', '72']))
Example #43
0
 def test_run(self, mock_get):
     """Verify the main CLI function can be called."""
     main.main(args=[])
     mock_get.assert_called_once_with(None)
Example #44
0
 def test_export_tree_xlsx(self):
     """Verify 'doorstop export' can create an XLSX directory."""
     path = os.path.join(self.temp, 'all')
     self.assertIs(None, main(['export', 'all', path, '--xlsx']))
     self.assertTrue(os.path.isdir(path))
Example #45
0
 def test_publish_document_without_child_links(self):
     """Verify 'doorstop publish' can create output without child links."""
     self.assertIs(None, main(['publish', 'tut', '--no-child-links']))
     self.assertFalse(settings.PUBLISH_CHILD_LINKS)
Example #46
0
 def test_publish_document(self):
     """Verify 'doorstop publish' can create output."""
     self.assertIs(None, main(['publish', 'tut']))
     self.assertTrue(settings.PUBLISH_CHILD_LINKS)
Example #47
0
 def test_publish_document(self):
     """Verify 'doorstop publish' can create output."""
     self.assertIs(None, main(['publish', 'tut']))
     self.assertTrue(settings.PUBLISH_CHILD_LINKS)
Example #48
0
 def test_publish_document_without_body_levels(self):
     """Verify 'doorstop publish' can create output without body levels."""
     self.assertIs(None, main(['publish', 'tut', '--no-body-levels']))
     self.assertFalse(settings.PUBLISH_BODY_LEVELS)
Example #49
0
 def test_import_document_with_parent(self):
     """Verify 'doorstop import' can import a document with a parent."""
     self.assertIs(
         None,
         main(['import', '--document', 'TMP', 'tmp', '--parent', 'REQ']))
Example #50
0
 def test_publish_document_markdown(self):
     """Verify 'doorstop publish' can create Markdown output."""
     self.assertIs(None, main(['publish', 'req', '--markdown']))
Example #51
0
 def test_import_item(self):
     """Verify 'doorstop import' can import an item.."""
     self.assertIs(None, main(['import', '--item', 'REQ', 'REQ099']))
Example #52
0
 def test_publish_document_html_file(self):
     """Verify 'doorstop publish' can create an HTML file."""
     path = os.path.join(self.temp, 'req.html')
     self.assertIs(None, main(['publish', 'req', path]))
     self.assertTrue(os.path.isfile(path))
Example #53
0
 def test_main_custom_root(self):
     """Verify 'doorstop' can be provided a custom root path."""
     os.chdir(self.temp)
     self.assertIs(None, main(['--project', '.']))
Example #54
0
 def test_verbose_0(self):
     """Verify verbose level 0 can be set."""
     self.assertIs(None, main([]))
Example #55
0
 def test_main(self):
     """Verify 'doorstop' can be called."""
     self.assertIs(None, main([]))
Example #56
0
 def test_verbose_5(self):
     """Verify verbose level 5 cannot be set."""
     self.assertIs(None, main(['-vvvvv']))
     self.assertEqual(4, common.verbosity)
Example #57
0
 def test_export_tree_xlsx(self):
     """Verify 'doorstop export' can create an XLSX directory."""
     path = os.path.join(self.temp, 'all')
     self.assertIs(None, main(['export', 'all', path, '--xlsx']))
     self.assertTrue(os.path.isdir(path))
Example #58
0
 def test_delete(self):
     """Verify 'doorstop delete' can be called."""
     main(['create', 'PREFIX', 'prefix'])
     self.assertIs(None, main(['delete', 'PREFIX']))
Example #59
0
 def test_publish_document_html(self):
     """Verify 'doorstop publish' can create HTML output."""
     self.assertIs(None, main(['publish', 'hlt', '--html']))