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 main(argv=sys.argv): args = parse_args(argv) if args.verbose: logger.setLevel(logging.INFO) if args.debug: logger.setLevel(logging.DEBUG) try: site = Site(args.site) valid, message = site.is_valid() if not valid: raise AbortError(_('Invalid site source: {0}').format(message)) config = build_config(site.config_file, args) director = Director(config, site) director.produce() print(_('Complete.')) except AbortError as abort: logger.error(str(abort)) sys.exit(_('Incomplete.'))
def make_site(self): """Make a valid site instance.""" site = tempfile.mkdtemp() open(os.path.join(site, 'template.html'), 'w').close() return Site(site)
def run(self, args): site = Site.build(args) director = prepare_director(args, site) director.produce() serve(site, director)
def run(self, args): site = Site.build(args) director = prepare_director(args, site) director.produce() finish()