Example #1
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
Example #2
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
Example #3
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
Example #4
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
Example #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(str(c))
    assert not c.exists
Example #6
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
Example #7
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()
Example #8
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()
Example #9
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)
Example #10
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")
Example #11
0
 def __init__(self, source):
     super(Processable, self).__init__()
     self.source = FS.file_or_folder(source)
     self.is_processable = True
     self.uses_template = True
Example #12
0
def test_file_or_folder():
    f = FS.file_or_folder(__file__)
    assert isinstance(f, File)
    f = FS.file_or_folder(File(__file__).parent)
    assert isinstance(f, Folder)
Example #13
0
 def __init__(self, source):
     super(Processable, self).__init__()
     self.source = FS.file_or_folder(source)
     self.is_processable = True
     self.uses_template = True
Example #14
0
def test_name():
    f = FS(__file__)
    assert f.name == os.path.basename(__file__)
Example #15
0
def test_file_or_folder():
    f = FS.file_or_folder(__file__)
    assert isinstance(f, File)
    f = FS.file_or_folder(File(__file__).parent)
    assert isinstance(f, Folder)
Example #16
0
def test_representation():
    f = FS(__file__)
    assert f.path == __file__
    assert unicode(f) == __file__
    assert repr(f) == __file__