Example #1
0
    def test_copying_media(self):

        docs_dir = tempfile.mkdtemp()
        site_dir = tempfile.mkdtemp()
        try:
            # Create a markdown file, image, dot file and dot directory.
            open(os.path.join(docs_dir, 'index.md'), 'w').close()
            open(os.path.join(docs_dir, 'img.jpg'), 'w').close()
            open(os.path.join(docs_dir, '.hidden'), 'w').close()
            os.mkdir(os.path.join(docs_dir, '.git'))
            open(os.path.join(docs_dir, '.git/hidden'), 'w').close()

            conf = config.validate_config({
                'site_name': 'Example',
                'docs_dir': docs_dir,
                'site_dir': site_dir
            })
            build.build(conf)

            # Verify only the markdown (coverted to html) and the image are copied.
            self.assertTrue(
                os.path.isfile(os.path.join(site_dir, 'index.html')))
            self.assertTrue(os.path.isfile(os.path.join(site_dir, 'img.jpg')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, '.hidden')))
            self.assertFalse(
                os.path.isfile(os.path.join(site_dir, '.git/hidden')))
        finally:
            shutil.rmtree(docs_dir)
            shutil.rmtree(site_dir)
Example #2
0
    def test_copying_media(self):

        docs_dir = tempfile.mkdtemp()
        site_dir = tempfile.mkdtemp()
        try:
            # Create a markdown file, image, dot file and dot directory.
            open(os.path.join(docs_dir, 'index.md'), 'w').close()
            open(os.path.join(docs_dir, 'img.jpg'), 'w').close()
            open(os.path.join(docs_dir, '.hidden'), 'w').close()
            os.mkdir(os.path.join(docs_dir, '.git'))
            open(os.path.join(docs_dir, '.git/hidden'), 'w').close()

            conf = config.validate_config({
                'site_name': 'Example',
                'docs_dir': docs_dir,
                'site_dir': site_dir
            })
            build.build(conf)

            # Verify only the markdown (coverted to html) and the image are copied.
            self.assertTrue(os.path.isfile(os.path.join(site_dir, 'index.html')))
            self.assertTrue(os.path.isfile(os.path.join(site_dir, 'img.jpg')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, '.hidden')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, '.git/hidden')))
        finally:
            shutil.rmtree(docs_dir)
            shutil.rmtree(site_dir)
Example #3
0
File: test.py Project: jpush/mkdocs
 def test_default_pages(self):
     tmp_dir = tempfile.mkdtemp()
     try:
         open(os.path.join(tmp_dir, "index.md"), "w").close()
         open(os.path.join(tmp_dir, "about.md"), "w").close()
         conf = config.validate_config({"site_name": "Example", "docs_dir": tmp_dir})
         self.assertEqual(conf["pages"], ["index.md", "about.md"])
     finally:
         shutil.rmtree(tmp_dir)
Example #4
0
 def test_default_pages(self):
     tmp_dir = tempfile.mkdtemp()
     try:
         open(os.path.join(tmp_dir, 'index.md'), 'w').close()
         open(os.path.join(tmp_dir, 'about.md'), 'w').close()
         conf = config.validate_config({
             'site_name': 'Example',
             'docs_dir': tmp_dir
         })
         self.assertEqual(conf['pages'], ['index.md', 'about.md'])
     finally:
         shutil.rmtree(tmp_dir)
Example #5
0
 def test_default_pages(self):
     tmp_dir = tempfile.mkdtemp()
     try:
         open(os.path.join(tmp_dir, 'index.md'), 'w').close()
         open(os.path.join(tmp_dir, 'about.md'), 'w').close()
         conf = config.validate_config({
             'site_name': 'Example',
             'docs_dir': tmp_dir
         })
         self.assertEqual(conf['pages'], ['index.md', 'about.md'])
     finally:
         shutil.rmtree(tmp_dir)
Example #6
0
    def test_copying_media(self):

        docs_dir = tempfile.mkdtemp()
        site_dir = tempfile.mkdtemp()
        try:
            # Create a non-empty markdown file, image, dot file and dot directory.
            f = open(os.path.join(docs_dir, 'index.md'), 'w')
            f.write(
                dedent("""
                page_title: custom title

                # Heading 1

                This is some text.

                # Heading 2

                And some more text.
            """))
            f.close()
            open(os.path.join(docs_dir, 'img.jpg'), 'w').close()
            open(os.path.join(docs_dir, '.hidden'), 'w').close()
            os.mkdir(os.path.join(docs_dir, '.git'))
            open(os.path.join(docs_dir, '.git/hidden'), 'w').close()

            conf = config.validate_config({
                'site_name': 'Example',
                'docs_dir': docs_dir,
                'site_dir': site_dir
            })
            build.build(conf)

            # Verify only the markdown (coverted to html) and the image are copied.
            self.assertTrue(
                os.path.isfile(os.path.join(site_dir, 'index.html')))
            self.assertTrue(os.path.isfile(os.path.join(site_dir, 'img.jpg')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, '.hidden')))
            self.assertFalse(
                os.path.isfile(os.path.join(site_dir, '.git/hidden')))
        finally:
            shutil.rmtree(docs_dir)
            shutil.rmtree(site_dir)
Example #7
0
    def test_copying_media(self):

        docs_dir = tempfile.mkdtemp()
        site_dir = tempfile.mkdtemp()
        try:
            # Create a non-empty markdown file, image, dot file and dot directory.
            f = open(os.path.join(docs_dir, 'index.md'), 'w')
            f.write(dedent("""
                page_title: custom title

                # Heading 1

                This is some text.

                # Heading 2

                And some more text.
            """))
            f.close()
            open(os.path.join(docs_dir, 'img.jpg'), 'w').close()
            open(os.path.join(docs_dir, '.hidden'), 'w').close()
            os.mkdir(os.path.join(docs_dir, '.git'))
            open(os.path.join(docs_dir, '.git/hidden'), 'w').close()

            conf = config.validate_config({
                'site_name': 'Example',
                'docs_dir': docs_dir,
                'site_dir': site_dir
            })
            build.build(conf)

            # Verify only the markdown (coverted to html) and the image are copied.
            self.assertTrue(os.path.isfile(os.path.join(site_dir, 'index.html')))
            self.assertTrue(os.path.isfile(os.path.join(site_dir, 'img.jpg')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, '.hidden')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, '.git/hidden')))
        finally:
            shutil.rmtree(docs_dir)
            shutil.rmtree(site_dir)
Example #8
0
 def load_missing_site_name():
     config.validate_config({})
Example #9
0
 def load_missing_site_name():
     config.validate_config({})