Exemplo n.º 1
0
    def test_generates_with_user_specified_outdir(self):
        config = Configuration()
        config.outdir = tempfile.mkdtemp()
        site = self.factory.make_site()
        marker = 'marker.txt'
        open(os.path.join(site.path, marker), 'w').close()
        director = Director(config, site)

        director.produce()

        out_marker = os.path.join(config.outdir, marker)
        self.assertTrue(os.path.exists(out_marker))
Exemplo n.º 2
0
    def test_process_directory_triggers_pre_composition(self, signals):
        config = Configuration()
        site = self.factory.make_site()
        director = Director(config, site, [])
        config.outdir = os.path.join(site.path, 'outdir')
        os.mkdir(config.outdir)
        directory = os.path.join(site.path, 'directory')
        os.mkdir(directory)

        director.process_directory(directory)

        signals.pre_composition.send.assert_called_once_with(director)
Exemplo n.º 3
0
    def test_process_directory_triggers_pre_composition(self, signals):
        config = Configuration()
        site = self.factory.make_site()
        director = Director(config, site, [])
        config.outdir = os.path.join(site.path, 'outdir')
        os.mkdir(config.outdir)
        directory = os.path.join(site.path, 'directory')
        os.mkdir(directory)

        director.process_directory(directory)

        signals.pre_composition.send.assert_called_once_with(director)
Exemplo n.º 4
0
    def test_file_in_source_and_outdir_is_ignored(self):
        """A source file is ignored when the source dir is in the outdir."""
        config = Configuration()
        config.outdir = tempfile.mkdtemp()
        site_path = os.path.join(config.outdir, 'site')
        site = Site(site_path)
        director = Director(config, site, [])
        fake_file = os.path.join(site_path, 'fake')

        is_in_output = director.is_in_output(fake_file)

        self.assertFalse(is_in_output)
Exemplo n.º 5
0
    def test_generates_with_user_specified_outdir(self):
        config = Configuration()
        config.outdir = tempfile.mkdtemp()
        site = self.factory.make_site()
        marker = 'marker.txt'
        open(os.path.join(site.path, marker), 'w').close()
        director = Director(config, site, [])

        director.produce()

        out_marker = os.path.join(config.outdir, marker)
        self.assertTrue(os.path.exists(out_marker))
Exemplo n.º 6
0
    def test_file_in_source_and_outdir_is_ignored(self):
        """A source file is ignored when the source dir is in the outdir."""
        config = Configuration()
        config.outdir = tempfile.mkdtemp()
        site_path = os.path.join(config.outdir, 'site')
        site = Site(site_path)
        director = Director(config, site, [])
        fake_file = os.path.join(site_path, 'fake')

        is_in_output = director.is_in_output(fake_file)

        self.assertFalse(is_in_output)
Exemplo n.º 7
0
    def test_process_file_ignores_templates(self):
        config = Configuration()
        site = self.factory.make_site()
        default = os.path.join(site.path, 'template.html')
        open(default, 'w').close()
        config.outdir = os.path.join(site.path, 'outdir')
        os.mkdir(config.outdir)
        director = Director(config, site, [])

        director.process_file(default)

        default_output = os.path.join(config.outdir, 'template.html')
        self.assertFalse(os.path.exists(default_output))
Exemplo n.º 8
0
    def test_process_file_ignores_templates(self):
        config = Configuration()
        site = self.factory.make_site()
        default = os.path.join(site.path, 'template.html')
        open(default, 'w').close()
        config.outdir = os.path.join(site.path, 'outdir')
        os.mkdir(config.outdir)
        director = Director(config, site, [])

        director.process_file(default)

        default_output = os.path.join(config.outdir, 'template.html')
        self.assertFalse(os.path.exists(default_output))
Exemplo n.º 9
0
    def test_process_directory_ignores_templates(self):
        config = Configuration()
        site = self.factory.make_site()
        config.outdir = os.path.join(site.path, 'outdir')
        os.mkdir(config.outdir)
        director = Director(config, site, [])
        directory = os.path.join(director.catalog.templates_path, 'test')
        os.makedirs(directory)

        director.process_directory(directory)

        directory_output = os.path.join(
            config.outdir, director.catalog.TEMPLATES_DIR, 'test')
        self.assertFalse(os.path.exists(directory_output))
Exemplo n.º 10
0
    def test_process_directory_ignores_templates(self):
        config = Configuration()
        site = self.factory.make_site()
        config.outdir = os.path.join(site.path, 'outdir')
        os.mkdir(config.outdir)
        director = Director(config, site, [])
        directory = os.path.join(director.catalog.templates_path, 'test')
        os.makedirs(directory)

        director.process_directory(directory)

        directory_output = os.path.join(config.outdir,
                                        director.catalog.TEMPLATES_DIR, 'test')
        self.assertFalse(os.path.exists(directory_output))
Exemplo n.º 11
0
    def test_process_directory_ignores_directories_already_in_output(self):
        # Avoid processing directories in output for the same reason that
        # file processing is skipped.
        config = Configuration()
        site = self.factory.make_site()
        config.outdir = os.path.join(site.path, 'outdir')
        os.mkdir(config.outdir)
        directory = os.path.join(config.outdir, 'directory')
        os.mkdir(directory)
        director = Director(config, site, [])

        director.process_directory(directory)

        directory_output = os.path.join(config.outdir, 'outdir', 'directory')
        self.assertFalse(os.path.exists(directory_output))
Exemplo n.º 12
0
    def test_process_directory_ignores_directories_already_in_output(self):
        # Avoid processing directories in output for the same reason that
        # file processing is skipped.
        config = Configuration()
        site = self.factory.make_site()
        config.outdir = os.path.join(site.path, 'outdir')
        os.mkdir(config.outdir)
        directory = os.path.join(config.outdir, 'directory')
        os.mkdir(directory)
        director = Director(config, site, [])

        director.process_directory(directory)

        directory_output = os.path.join(config.outdir, 'outdir', 'directory')
        self.assertFalse(os.path.exists(directory_output))
Exemplo n.º 13
0
    def test_process_file_ignores_files_already_in_output(self):
        # This condition is checked because the output directory can be within
        # the source (e.g., the default of storing results in 'output'). If
        # the watcher is watching for any changes in site source, then
        # processing files in the output directory could lead the watcher into
        # an infinite loop.
        config = Configuration()
        site = self.factory.make_site()
        config.outdir = os.path.join(site.path, 'outdir')
        os.mkdir(config.outdir)
        marker = os.path.join(config.outdir, 'marker.md')
        open(marker, 'w').close()
        director = Director(config, site, [])

        director.process_file(marker)

        marker_output = os.path.join(config.outdir, 'marker.html')
        self.assertFalse(os.path.exists(marker_output))
Exemplo n.º 14
0
    def test_process_file_ignores_files_already_in_output(self):
        # This condition is checked because the output directory can be within
        # the source (e.g., the default of storing results in 'output'). If
        # the watcher is watching for any changes in site source, then
        # processing files in the output directory could lead the watcher into
        # an infinite loop.
        config = Configuration()
        site = self.factory.make_site()
        config.outdir = os.path.join(site.path, 'outdir')
        os.mkdir(config.outdir)
        marker = os.path.join(config.outdir, 'marker.md')
        open(marker, 'w').close()
        director = Director(config, site, [])

        director.process_file(marker)

        marker_output = os.path.join(config.outdir, 'marker.html')
        self.assertFalse(os.path.exists(marker_output))
Exemplo n.º 15
0
 def setUp(self):
     config = Configuration()
     config.outdir = tempfile.mkdtemp()
     self.site = self.factory.make_site()
     self.director = Director(config, self.site, [])
Exemplo n.º 16
0
 def setUp(self):
     config = Configuration()
     config.outdir = tempfile.mkdtemp()
     self.site = self.factory.make_site()
     self.director = Director(config, self.site, [])