def test_finds_valid_site_root_from_conf(self): original = os.getcwd() valid_site = os.path.realpath(tempfile.mkdtemp()) open(os.path.join(valid_site, Site.CONFIG), 'w').close() os.chdir(valid_site) site = Site() self.assertEqual(valid_site, site.path) os.chdir(original)
def test_site_has_absolute_path(self): original = os.getcwd() tempdir = os.path.realpath(tempfile.mkdtemp()) site_path = os.path.join(tempdir, 'site') os.mkdir(site_path) os.chdir(tempdir) site = Site('site') self.assertEqual(site_path, site.path) os.chdir(original)
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)
def make_site(self): """Make a valid site instance.""" site = tempfile.mkdtemp() open(os.path.join(site, 'template.html'), 'w').close() return Site(site)