def test_find_layout_from_env_var(): f = Layout.find_layout() LAYOUT_ROOT.make() f.copy_to(LAYOUT_ROOT) os.environ[HYDE_DATA] = str(DATA_ROOT) f = Layout.find_layout() assert f.parent == LAYOUT_ROOT assert f.name == 'basic' assert f.child_folder('layout').exists del os.environ[HYDE_DATA]
def test_find_layout_from_env_var(): f = Layout.find_layout() LAYOUT_ROOT.make() f.copy_to(LAYOUT_ROOT) os.environ[HYDE_DATA] = unicode(DATA_ROOT) f = Layout.find_layout() assert f.parent == LAYOUT_ROOT assert f.name == 'basic' assert f.child_folder('layout').exists del os.environ[HYDE_DATA]
def test_find_layout_from_env_var(): f = Layout.find_layout() LAYOUT_ROOT.make() f.copy_to(LAYOUT_ROOT) os.environ[HYDE_DATA] = str(DATA_ROOT) f = Layout.find_layout() assert f.parent == LAYOUT_ROOT assert f.name == "basic" assert f.child_folder("layout").exists del os.environ[HYDE_DATA]
def test_ensure_no_exception_when_forced(): e = Engine(raise_exceptions=True) TEST_SITE.child_folder('layout').make() e.run(e.parse(['-s', str(TEST_SITE), 'create', '-f'])) verify_site_contents(TEST_SITE, Layout.find_layout()) TEST_SITE.delete() TEST_SITE.child_folder('content').make() e.run(e.parse(['-s', str(TEST_SITE), 'create', '-f'])) verify_site_contents(TEST_SITE, Layout.find_layout()) TEST_SITE.delete() TEST_SITE.make() File(TEST_SITE.child('site.yaml')).write("Hey") e.run(e.parse(['-s', str(TEST_SITE), 'create', '-f'])) verify_site_contents(TEST_SITE, Layout.find_layout())
def test_ensure_no_exception_when_forced(): e = Engine(raise_exceptions=True) TEST_SITE.child_folder("layout").make() e.run(e.parse(["-s", str(TEST_SITE), "create", "-f"])) verify_site_contents(TEST_SITE, Layout.find_layout()) TEST_SITE.delete() TEST_SITE.child_folder("content").make() e.run(e.parse(["-s", str(TEST_SITE), "create", "-f"])) verify_site_contents(TEST_SITE, Layout.find_layout()) TEST_SITE.delete() TEST_SITE.make() File(TEST_SITE.child("site.yaml")).write("Hey") e.run(e.parse(["-s", str(TEST_SITE), "create", "-f"])) verify_site_contents(TEST_SITE, Layout.find_layout())
def create(self, args): """ The create command. Creates a new site from the template at the given sitepath. """ self.main(args) sitepath = Folder(Folder(args.sitepath).fully_expanded_path) markers = ['content', 'layout', 'site.yaml'] exists = any((FS(sitepath.child(item)).exists for item in markers)) if exists and not args.overwrite: raise HydeException( "The given site path [%s] already contains a hyde site." " Use -f to overwrite." % sitepath) layout = Layout.find_layout(args.layout) logger.info( "Creating site at [%s] with layout [%s]" % (sitepath, layout)) if not layout or not layout.exists: raise HydeException( "The given layout is invalid. Please check if you have the" " `layout` in the right place and the environment variable(%s)" " has been setup properly if you are using custom path for" " layouts" % HYDE_DATA) layout.copy_contents_to(args.sitepath) logger.info("Site creation complete")
def create(self, args): """ The create command. Creates a new site from the template at the given sitepath. """ self.main(args) sitepath = Folder(Folder(args.sitepath).fully_expanded_path) if sitepath.exists and not args.overwrite: raise HydeException( "The given site path[%s] is not empty" % sitepath) layout = Layout.find_layout(args.layout) logger.info( "Creating site at [%s] with layout [%s]" % (sitepath, layout)) if not layout or not layout.exists: raise HydeException( "The given layout is invalid. Please check if you have the" " `layout` in the right place and the environment variable(%s)" " has been setup properly if you are using custom path for" " layouts" % HYDE_DATA) layout.copy_contents_to(args.sitepath) logger.info("Site creation complete")
def create(self, args): """ The create command. Creates a new site from the template at the given sitepath. """ self.main(args) sitepath = Folder(Folder(args.sitepath).fully_expanded_path) if sitepath.exists and not args.overwrite: raise HydeException("The given site path [%s] already exists." " Use -f to overwrite." % sitepath) layout = Layout.find_layout(args.layout) logger.info("Creating site at [%s] with layout [%s]" % (sitepath, layout)) if not layout or not layout.exists: raise HydeException( "The given layout is invalid. Please check if you have the" " `layout` in the right place and the environment variable(%s)" " has been setup properly if you are using custom path for" " layouts" % HYDE_DATA) layout.copy_contents_to(args.sitepath) logger.info("Site creation complete")
def create(self, args): """ The create command. Creates a new site from the template at the given sitepath. """ sitepath = self.main(args) markers = ['content', 'layout', 'site.yaml'] exists = any((FS(sitepath.child(item)).exists for item in markers)) if exists and not args.overwrite: raise HydeException( "The given site path [%s] already contains a hyde site." " Use -f to overwrite." % sitepath) layout = Layout.find_layout(args.layout) self.logger.info("Creating site at [%s] with layout [%s]" % (sitepath, layout)) if not layout or not layout.exists: raise HydeException( "The given layout is invalid. Please check if you have the" " `layout` in the right place and the environment variable(%s)" " has been setup properly if you are using custom path for" " layouts" % HYDE_DATA) layout.copy_contents_to(args.sitepath) self.logger.info("Site creation complete")
def test_ensure_can_create_site_at_user(): e = Engine(raise_exceptions=True) TEST_SITE_AT_USER.delete() e.run(e.parse(['-s', str(TEST_SITE_AT_USER), 'create', '-f'])) verify_site_contents(TEST_SITE_AT_USER, Layout.find_layout())
def test_ensure_no_exception_when_sitepath_does_not_exist(): e = Engine(raise_exceptions=True) TEST_SITE.delete() e.run(e.parse(['-s', str(TEST_SITE), 'create', '-f'])) verify_site_contents(TEST_SITE, Layout.find_layout())
def test_ensure_no_exception_when_empty_site_exists(): e = Engine(raise_exceptions=True) e.run(e.parse(['-s', str(TEST_SITE), 'create'])) verify_site_contents(TEST_SITE, Layout.find_layout())
def test_find_layout_from_package_dir(): f = Layout.find_layout() assert f.name == 'basic' assert f.child_folder('layout').exists
def test_find_layout_from_package_dir(): f = Layout.find_layout() assert f.name == "basic" assert f.child_folder("layout").exists