Ejemplo n.º 1
0
def test_exists():
    p = FS(__file__)
    assert p.exists
    p = FS(__file__ + "_some_junk")
    assert not p.exists
    f = FS(__file__).parent.parent
    assert f.exists
    f = FS(__file__).parent.child_folder('templates')
    assert f.exists
Ejemplo n.º 2
0
def test_equals():
    f = FS('/blog/2010/december')
    g = FS('/blog/2010/december')
    h = FS('/blog/2010/december/')
    i = FS('/blog/2010/november')
    assert f == f.path
    assert f == g
    assert f == h
    assert f != i
Ejemplo n.º 3
0
def test_remove_folder():
    f = FS(__file__).parent
    c = f.child_folder('__test__')
    assert not c.exists
    c.make()
    assert c.exists
    c.delete()
    assert not c.exists
Ejemplo n.º 4
0
    def full_url(self, path):
        """
        Determines if the given path is media or content based on the
        configuration and returns the appropriate url.
        """

        if self.is_media(path):
            return self.media_url(
                FS(path).get_relative_path(self.config.media_root_path))
        else:
            return self.content_url(path)
Ejemplo n.º 5
0
def test_create_folder():
    f = FS(__file__).parent
    assert f.exists
    f.make()
    assert True  # No Exceptions
    c = f.child_folder('__test__')
    assert not c.exists
    c.make()
    assert c.exists
    shutil.rmtree(unicode(c))
    assert not c.exists
Ejemplo n.º 6
0
def test_can_remove_file():
    f = FS(__file__).parent
    c = f.child_folder('__test__')
    c.make()
    assert c.exists
    txt = "abc"
    abc = File(c.child('abc.txt'))
    abc.write(txt)
    assert abc.exists
    abc.delete()
    assert not abc.exists
    abc.delete()
    assert True  # No Exception
    c.delete()
Ejemplo n.º 7
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)
        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")
Ejemplo n.º 8
0
def test_name():
    f = FS(__file__)
    assert f.name == os.path.basename(__file__)
Ejemplo n.º 9
0
def test_representation():
    f = FS(__file__)
    assert f.path == __file__
    assert unicode(f) == __file__
    assert repr(f) == __file__