コード例 #1
0
ファイル: test_hotdoc.py プロジェクト: tense-du/hotdoc
 def test_makefile_path(self):
     args = ['--makefile-path']
     f = io.StringIO()
     with redirect_stdout(f):
         res = run(args)
     self.assertEqual(res, 0)
     path = f.getvalue().strip()
     self.assertTrue(os.path.exists(path))
コード例 #2
0
ファイル: test_hotdoc.py プロジェクト: tense-du/hotdoc
 def test_error(self):
     args = [
         '--index',
         os.path.join(self.__md_dir, 'index.markdown'), '--output',
         self.__output_dir, 'run'
     ]
     res = run(args)
     self.assertEqual(res, 1)
コード例 #3
0
ファイル: test_hotdoc.py プロジェクト: tense-du/hotdoc
 def test_version(self):
     from hotdoc.utils.setup_utils import VERSION
     args = ['--version']
     f = io.StringIO()
     with redirect_stdout(f):
         res = run(args)
     self.assertEqual(res, 0)
     self.assertEqual(f.getvalue().strip(), VERSION)
コード例 #4
0
ファイル: test_hotdoc.py プロジェクト: tense-du/hotdoc
    def test_conf(self):
        index_path = self.__create_md_file('index.markdown',
                                           "## A very simple index\n")
        sitemap_path = self.__create_sitemap('sitemap.txt', 'index.markdown')
        conf = {
            'index': index_path,
            'output': self.__output_dir,
            'project_name': 'test-project',
            'project_version': '0.1',
            'sitemap': sitemap_path
        }

        self.__create_conf_file('hotdoc.json', conf)
        args = ['conf']
        res = run(args)
        self.assertEqual(res, 0)
        with open(os.path.join(self._test_dir, 'hotdoc.json')) as _:
            updated_conf = json.loads(_.read())
        self.assertDictEqual(updated_conf, conf)

        args = ['conf', '--project-version', '0.2']
        res = run(args)
        self.assertEqual(res, 0)
        with open(os.path.join(self._test_dir, 'hotdoc.json')) as _:
            updated_conf = json.loads(_.read())
        self.assertEqual(updated_conf.get('project_version'), '0.2')

        conf = updated_conf
        args = ['conf', '--output-conf-file', 'new_hotdoc.json']
        res = run(args)
        self.assertEqual(res, 0)
        with open(os.path.join(self._test_dir, 'new_hotdoc.json')) as _:
            new_conf = json.loads(_.read())
        self.assertDictEqual(new_conf, conf)

        f = io.StringIO()
        args = ['--get-conf-key', 'project_version']
        with redirect_stdout(f):
            res = run(args)
        self.assertEqual(res, 0)
        self.assertEqual(f.getvalue().strip(), '0.2')

        f = io.StringIO()
        args = [
            '--get-conf-key', 'project_version', '--project-version', '0.3'
        ]
        with redirect_stdout(f):
            res = run(args)
        self.assertEqual(res, 0)
        self.assertEqual(f.getvalue().strip(), '0.3')

        f = io.StringIO()
        args = ['--get-conf-path', 'index']
        with redirect_stdout(f):
            res = run(args)
        self.assertEqual(res, 0)
        self.assertEqual(f.getvalue().strip(),
                         os.path.relpath(index_path, os.getcwd()))
コード例 #5
0
ファイル: test_hotdoc.py プロジェクト: gdesmott/hotdoc
    def test_basic(self):
        self.__create_md_file('index.markdown',
                              "## A very simple index\n")

        with open(os.path.join(self.__md_dir, 'sitemap.txt'), 'w') as _:
            _.write('index.markdown')

        args = ['--index', os.path.join(self.__md_dir, 'index.markdown'),
                '--output', self.__output_dir,
                '--sitemap', os.path.join(self.__md_dir, 'sitemap.txt'),
                'run']
        res = run(args)
        self.assertEqual(res, 0)

        self.assertOutput(1)
コード例 #6
0
ファイル: test_hotdoc.py プロジェクト: andrewshadura/hotdoc
    def test_basic(self):
        self.__create_md_file('index.markdown', "## A very simple index\n")

        with open(os.path.join(self.__md_dir, 'sitemap.txt'), 'w') as _:
            _.write('index.markdown')

        args = [
            '--index',
            os.path.join(self.__md_dir, 'index.markdown'), '--output',
            self.__output_dir, '--sitemap',
            os.path.join(self.__md_dir, 'sitemap.txt'), 'run'
        ]
        res = run(args)
        self.assertEqual(res, 0)

        self.assertOutput(1)
コード例 #7
0
ファイル: test_hotdoc.py プロジェクト: tense-du/hotdoc
    def test_implicit_conf_file(self):
        index_path = self.__create_md_file('index.markdown',
                                           "## A very simple index\n")
        sitemap_path = self.__create_sitemap('sitemap.txt', 'index.markdown')
        self.__create_conf_file(
            'hotdoc.json', {
                'index': index_path,
                'output': self.__output_dir,
                'project_name': 'test-project',
                'project_version': '0.1',
                'sitemap': sitemap_path
            })

        args = ['run']

        res = run(args)
        self.assertEqual(res, 0)
        self.assertOutput(1)
コード例 #8
0
ファイル: test_hotdoc.py プロジェクト: tense-du/hotdoc
    def test_private_folder(self):
        self.__create_md_file('index.markdown', "## A very simple index\n")

        with open(os.path.join(self.__md_dir, 'sitemap.txt'), 'w') as _:
            _.write('index.markdown')

        args = [
            '--index',
            os.path.join(self.__md_dir, 'index.markdown'), '--output',
            self.__output_dir, '--project-name', 'test-project',
            '--project-version', '0.1', '--sitemap',
            os.path.join(self.__md_dir, 'sitemap.txt'), '--get-private-folder'
        ]

        f = io.StringIO()
        with redirect_stdout(f):
            res = run(args)
        self.assertEqual(res, 0)
        path = f.getvalue().strip()
        self.assertTrue(os.path.basename(path).startswith('hotdoc-private'))
コード例 #9
0
ファイル: test_hotdoc.py プロジェクト: gdesmott/hotdoc
 def test_error(self):
     args = ['--index', os.path.join(self.__md_dir, 'index.markdown'),
             '--output', self.__output_dir,
             'run']
     res = run(args)
     self.assertEqual(res, 1)