def test_command_upload_download(self): folder_name = "/test_folder5" file_name1 = "test_file4.txt" file_name2 = "test_file5.txt" file_path = folder_name + "/" + file_name1 file_descriptor = open(file_name1, "w+") content_file1 = "Hello PyClustering! Hello PyClustering! Hello PyClustering!" file_descriptor.write(content_file1) file_descriptor.close() client_task = task("mkdir", [folder_name]) task_handler(self.__token).process(client_task) self.assertTrue(self.__disk_client.directory_exist(folder_name)) client_task = task("upload", [file_name1, file_path]) task_handler(self.__token).process(client_task) self.assertTrue(self.__disk_client.file_exist(file_path)) client_task = task("download", [file_path, file_name2]) task_handler(self.__token).process(client_task) self.assertTrue(os.path.isfile(file_name2)) file_descriptor = open(file_name2, "r") content_file2 = file_descriptor.read() file_descriptor.close() self.assertEqual(content_file1, content_file2) self.assertTrue(self.__disk_client.delete(folder_name)) os.remove(file_name1) os.remove(file_name2)
def test_command_create(self): folder_name = "/test_folder4" client_task = task("mkdir", [folder_name]) task_handler(self.__token).process(client_task) self.assertTrue(self.__disk_client.directory_exist(folder_name)) self.assertTrue(self.__disk_client.delete(folder_name))
def run(): if len(sys.argv) == 2: client_task = task(sys.argv[1], []) token = "" elif len(sys.argv) < 3: raise SyntaxError("ERROR: Incorrect amount of arguments '%d' " "(please, see 'python3 ci/cloud --help')." % len(sys.argv)) else: token = sys.argv[1] action = sys.argv[2] params = sys.argv[3:] client_task = task(action, params) task_handler(token).process(client_task)