def do_vdir(self, args, arguments): """ :: Usage: vdir mkdir DIR vdir cd [DIR] vdir ls [DIR] vdir add [FILEENDPOINT] [DIR_AND_NAME] vdir delete [DIR_OR_NAME] vdir status [DIR_OR_NAME] vdir get NAME DESTINATION Arguments: DIR a directory name FILEENDPOINT location of file DIR_AND_NAME path of file link DIR_OR_NAME name of directory or link DESTINATION directory to download to NAME name of link Options: -f specify the file Descripton: A virtual directory is explained in our NIST doecumentation. It contains a number of links that point to other storage services on which the file is stored. The links include the provider, the name of the profider and its type are identified in the ~/.cloudmesh4.yaml file. the location is identified as {provider}:{directory}/{filensme} A cloudmesh directory can be used to uniquely specify the file: cm: name: the unique name of the file kind: vdir cloud: local directory: directory filename: filename directory: directory provider: provider created: date modified: date vdir get NAME DESTINATION locates the file with the name on a storage provider, and fetches it from there. """ print(arguments) d = Vdir() if arguments['add']: d.add(arguments.FILEENDPOINT, arguments.DIR_AND_NAME) elif arguments['ls']: d.ls(arguments.DIR) elif arguments['get']: d.get(arguments.NAME, arguments.DESTINATION) elif arguments['mkdir']: d.mkdir(arguments.DIR) elif arguments['cd']: d.cd(arguments.DIR) elif arguments['delete']: d.delete(arguments.DIR_OR_NAME) elif arguments['status']: d.status(arguments.DIR_OR_NAME)
def setup(): vdir = Vdir() return vdir
class Test_vdir: def setup(self): self.vdir = Vdir() self.endpoint = 'box:/test.txt' self.dir_and_name = '/testdir/test' self.dir = 'testdir' self.file = 'test' def test_collection(self): HEADING() col = self.vdir.col assert col.name == 'local-vdir' @pytest.fixture(scope='class') def dummy_file(self): self.vdir = Vdir() self.endpoint = 'box:/test.txt' self.dir_and_name = 'test' testfile = self.vdir.add(endpoint=self.endpoint, dir_and_name=self.dir_and_name) return testfile @pytest.fixture(scope='class') def dummy_dir(self): self.vdir = Vdir() self.dir = 'testdir' testdir = self.vdir.mkdir(dirname=self.dir) return testdir def test_mkdir(self, dummy_dir): HEADING() assert dummy_dir is not None def test_add(self, dummy_file): HEADING() assert dummy_file is not None def test_ls(self): HEADING() results = self.vdir.ls(directory=None) assert results is not None def test_get(self): HEADING() file = self.vdir.get(name=self.file, destination=None) assert file is not None def test_status(self): HEADING() file = self.vdir.status(dir_or_name=self.file) assert file is not None def test_cd(self): HEADING() self.vdir.cd(dirname=self.dir) assert self.vdir.directory == self.dir def test_delete(self): HEADING() self.vdir.delete(dir_or_name=self.file) self.vdir.delete(dir_or_name=self.dir)
def setup(self): self.vdir = Vdir() self.endpoint = 'box:/test.txt' self.dir_and_name = '/testdir/test' self.dir = 'testdir' self.file = 'test'
def dummy_dir(self): self.vdir = Vdir() self.dir = 'testdir' testdir = self.vdir.mkdir(dirname=self.dir) return testdir