Esempio n. 1
0
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]
Esempio n. 2
0
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]
Esempio n. 3
0
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]
Esempio n. 4
0
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())
Esempio n. 6
0
    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")
Esempio n. 7
0
 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")
Esempio n. 8
0
File: engine.py Progetto: semk/hyde
 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")
Esempio n. 9
0
    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")
Esempio n. 10
0
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())
Esempio n. 11
0
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())
Esempio n. 12
0
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())
Esempio n. 13
0
def test_find_layout_from_package_dir():
    f = Layout.find_layout()
    assert f.name == 'basic'
    assert f.child_folder('layout').exists
Esempio n. 14
0
def test_find_layout_from_package_dir():
    f = Layout.find_layout()
    assert f.name == 'basic'
    assert f.child_folder('layout').exists
Esempio n. 15
0
def test_find_layout_from_package_dir():
    f = Layout.find_layout()
    assert f.name == "basic"
    assert f.child_folder("layout").exists