def test_mkdir_rmdir(self): remote_folder, remote_name = self._get_remote_folder() self._call_shell_command("mkdir", remote_folder) output = self._call_shell_command("ls", helpers.get_remote_test_folder()) self.assertTrue(remote_name in output, "Expected folder not found. Received: %s" % (output, )) # The recurse is needed to compensate for a bug in GenomeSpace swift # which creates a .hidden file in each folder self._call_shell_command("rm", "-R", remote_folder) output = self._call_shell_command("ls", helpers.get_remote_test_folder()) self.assertTrue( remote_name not in output, "Expected folder to be deleted. Received: %s" % (output, ))
def test_mkdir_rmdir(self): client = helpers.get_genomespace_client() remote_folder1, remote_name1 = self._get_remote_folder() client.mkdir(remote_folder1) filelist = client.list(helpers.get_remote_test_folder()) found_file = [f for f in filelist.contents if self._adjust_gs_swift_bug(f.name) == remote_name1 and f.is_directory] self.assertTrue(len(found_file) == 1, "Expected to find one created folder") # The recurse is needed to compensate for a bug in GenomeSpace swift # which creates a .hidden file in each folder client.delete(remote_folder1, recurse=True) filelist = client.list(helpers.get_remote_test_folder()) found_file = [f for f in filelist.contents if self._adjust_gs_swift_bug(f.name) == remote_name1] self.assertTrue(len(found_file) == 0, "Expected folder to be deleted but it's not")
def test_list(self): local_test_file = self._get_test_file() remote_file_path, remote_name = self._get_remote_file() self._call_shell_command("cp", local_test_file, remote_file_path) output = self._call_shell_command( "ls", helpers.get_remote_test_folder()) self.assertTrue(remote_name in output, "Expected file not found. Received: %s" % (output,)) self._call_shell_command("rm", remote_file_path)
def test_list(self): client = helpers.get_genomespace_client() local_test_file = self._get_test_file() remote_file_path, remote_name = self._get_remote_file() client.copy(local_test_file, remote_file_path) filelist = client.list(helpers.get_remote_test_folder()) found_file = [f for f in filelist["contents"] if f["name"] == remote_name] self.assertTrue(len(found_file) == 1, "Expected file not found") client.delete(remote_file_path)
def test_list(self): client = helpers.get_genomespace_client() local_test_file = self._get_test_file() remote_file_path, remote_name = self._get_remote_file() client.copy(local_test_file, remote_file_path) filelist = client.list(helpers.get_remote_test_folder()) found_file = [f for f in filelist.contents if f.name == remote_name] self.assertTrue(len(found_file) == 1, "Expected file not found") client.delete(remote_file_path)
def test_list(self): local_test_file = self._get_test_file() remote_file_path, remote_name = self._get_remote_file() self._call_shell_command("cp", local_test_file, remote_file_path) output = self._call_shell_command("ls", helpers.get_remote_test_folder()) self.assertTrue(remote_name in output, "Expected file not found. Received: %s" % (output, )) self._call_shell_command("rm", remote_file_path)
def test_delete(self): local_test_file = self._get_test_file() remote_file_path, remote_name = self._get_remote_file() self._call_shell_command("cp", local_test_file, remote_file_path) self._call_shell_command("rm", remote_file_path) output = self._call_shell_command("ls", helpers.get_remote_test_folder()) self.assertFalse(remote_name in output, "File was found but should have been deleted")
def test_delete(self): local_test_file = self._get_test_file() remote_file_path, remote_name = self._get_remote_file() self._call_shell_command("cp", local_test_file, remote_file_path) self._call_shell_command("rm", remote_file_path) output = self._call_shell_command( "ls", helpers.get_remote_test_folder()) self.assertFalse(remote_name in output, "File was found but should have been deleted")
def test_delete(self): client = helpers.get_genomespace_client() local_test_file = self._get_test_file() remote_file_path, remote_name = self._get_remote_file() client.copy(local_test_file, remote_file_path) client.delete(remote_file_path) filelist = client.list(helpers.get_remote_test_folder()) found_file = [f for f in filelist.contents if f.name == remote_name] self.assertTrue(len(found_file) == 0, "File was found but should have been deleted")
def test_delete(self): client = helpers.get_genomespace_client() local_test_file = self._get_test_file() remote_file_path, remote_name = self._get_remote_file() client.copy(local_test_file, remote_file_path) client.delete(remote_file_path) filelist = client.list(helpers.get_remote_test_folder()) found_file = [f for f in filelist["contents"] if f["name"] == remote_name] self.assertTrue(len(found_file) == 0, "File was found but should have been deleted")
def test_delete_folder(self): local_test_folder = self._get_test_folder() remote_folder, remote_name = self._get_remote_folder() self._call_shell_command("mkdir", remote_folder) self._call_shell_command("cp", "-R", local_test_folder, remote_folder) self._call_shell_command("rm", "-R", remote_folder) output = self._call_shell_command("ls", helpers.get_remote_test_folder()) self.assertTrue( remote_name not in output, "Expected folder to be deleted. Received: %s" % (output, ))
def test_get_token_expiry(self): client = helpers.get_genomespace_client() genomespace_url = helpers.get_genomespace_url() # no gs-token, as have not yet performed any actions milliseconds_left = client.get_remaining_token_time(genomespace_url) self.assertTrue( milliseconds_left == 0, "Expected client not yet logged in to have no token expiry time") # now force a login and hence the client to get a gs-token client.list(helpers.get_remote_test_folder()) milliseconds_left = client.get_remaining_token_time(genomespace_url) self.assertTrue( milliseconds_left > 0, "Expected a logged in client to have a token expiry time")
def test_delete_folder(self): client = helpers.get_genomespace_client() local_test_folder = self._get_test_folder() remote_folder, remote_name = self._get_remote_folder() client.mkdir(remote_folder) client.copy(local_test_folder, remote_folder, recurse=True) client.delete(remote_folder, recurse=True) filelist = client.list(helpers.get_remote_test_folder()) found_folder = [f for f in filelist.contents if self._adjust_gs_swift_bug(f.name) == remote_name] self.assertTrue(len(found_folder) == 0, "Folder was found but should have been deleted")
def test_move(self): local_test_file = self._get_test_file() local_temp_file = self._get_temp_file() remote_file1, _ = self._get_remote_file() remote_file2, _ = self._get_remote_file() self._call_shell_command("cp", local_test_file, remote_file1) self._call_shell_command("mv", remote_file1, remote_file2) self._call_shell_command("cp", remote_file2, local_temp_file) self._call_shell_command("rm", remote_file2) output = self._call_shell_command("ls", helpers.get_remote_test_folder()) self.assertFalse(remote_file1 in output, "File was found but should have been moved") self.assertTrue(filecmp.cmp(local_test_file, local_temp_file)) os.remove(local_temp_file)
def test_move(self): local_test_file = self._get_test_file() local_temp_file = self._get_temp_file() remote_file1, _ = self._get_remote_file() remote_file2, _ = self._get_remote_file() self._call_shell_command("cp", local_test_file, remote_file1) self._call_shell_command("mv", remote_file1, remote_file2) self._call_shell_command("cp", remote_file2, local_temp_file) self._call_shell_command("rm", remote_file2) output = self._call_shell_command( "ls", helpers.get_remote_test_folder()) self.assertFalse(remote_file1 in output, "File was found but should have been deleted") self.assertTrue(filecmp.cmp(local_test_file, local_temp_file)) os.remove(local_temp_file)
def test_move(self): client = helpers.get_genomespace_client() local_test_file = self._get_test_file() local_temp_file = self._get_temp_file() remote_file1, _ = self._get_remote_file() remote_file2, _ = self._get_remote_file() client.copy(local_test_file, remote_file1) client.move(remote_file1, remote_file2) client.copy(remote_file2, local_temp_file) client.delete(remote_file2) filelist = client.list(helpers.get_remote_test_folder()) found_file = [f for f in filelist["contents"] if f["name"] == remote_file1] self.assertTrue(len(found_file) == 0, "File was found but should have been deleted") self.assertTrue(filecmp.cmp(local_test_file, local_temp_file)) os.remove(local_temp_file)
def test_move(self): client = helpers.get_genomespace_client() local_test_file = self._get_test_file() local_temp_file = self._get_temp_file() remote_file1, remote_name1 = self._get_remote_file() remote_file2, _ = self._get_remote_file() client.copy(local_test_file, remote_file1) client.move(remote_file1, remote_file2) client.copy(remote_file2, local_temp_file) client.delete(remote_file2) filelist = client.list(helpers.get_remote_test_folder()) found_file = [f for f in filelist.contents if f.name == remote_name1] self.assertTrue(len(found_file) == 0, "File was found but should have been moved") self.assertTrue(filecmp.cmp(local_test_file, local_temp_file)) os.remove(local_temp_file)
def _get_remote_file(self): filename = self._get_temp_filename() + ".txt" return (urljoin(helpers.get_remote_test_folder(), filename), filename)
def _get_remote_file(self): filename = self._get_temp_filename() return (urljoin(helpers.get_remote_test_folder(), filename), filename)
def _get_remote_folder(self): foldername = self._get_temp_filename() return (urljoin(helpers.get_remote_test_folder(), foldername) + "/", foldername)