def testCambioWD(self): """ Testeo del cambio del working directory. :return: void :rtype: None """ if VERBOSE: print_bars_console("Testeo del wd") print "Wd actual: ", self.fm.get_working_directory() b = self.fm.get_working_directory() if is_windows(): self.fm.set_working_directory("C:/") if VERBOSE: print "Wd actual: ", self.fm.get_working_directory() assert self.fm.get_working_directory() == "C:/", FILEMANAGER_ERROR_WD self.fm.restore_wd() if VERBOSE: print "Wd actual: ", self.fm.get_working_directory() assert self.fm.get_working_directory() == b, FILEMANAGER_ERROR_RESTORE_WD self.fm.set_working_directory(DIR_DATA_TEST) if VERBOSE: print "Wd actual: ", self.fm.get_working_directory() assert self.fm.get_working_directory() == DIR_DATA_TEST, FILEMANAGER_ERROR_WD del b
def testCompressedFileAlreadyExists(self): """ Testeo de una carpeta con archivos comprimidos que tienen el mismo nombre que una carpeta. :return: void :rtype: None """ self.fm.disable_extract_if_folder_already_exists() if VERBOSE: print_bars_console("Testeo carpeta con archivos comprimidos que ya existen como carpetas") print self.fm.inspect_single_file("Folder 8-COMPSD") t = ['Folder 8-COMPSD/Subfolder 1/Content 1.txt', \ 'Folder 8-COMPSD/Subfolder 1/Content 2.txt', \ 'Folder 8-COMPSD/Subfolder 1/Subfolder inside subfolder 1/Content 1.txt', \ 'Folder 8-COMPSD/Subfolder 1/Subfolder inside subfolder 1/Content 2.txt', \ 'Folder 8-COMPSD/Zip Folder/Rar Folder/Content Y.txt', \ 'Folder 8-COMPSD/Zip Folder/Rar Folder/Content Z.txt', \ 'Folder 8-COMPSD/Zip Folder/Rar Folder/Rar Folder - target/Content target.txt', \ 'Folder 8-COMPSD/Zip Folder/Rar Folder/Rar Folder/File C.txt', \ 'Folder 8-COMPSD/Zip Folder/Rar Folder/Rar Folder/File Z.txt', \ 'Folder 8-COMPSD/Zip Folder/Rar Folder/Rar Folder/Zip Folder TARGET/Parte1.java', \ 'Folder 8-COMPSD/Zip Folder/Rar Folder/Rar Folder/Zip Folder TARGET/Parte2.java', \ 'Folder 8-COMPSD/Zip Folder/Rar Folder/Subfolder with rar/Content 1.txt', \ 'Folder 8-COMPSD/Zip Folder/Rar Folder/Subfolder with rar/Content 2.txt', \ 'Folder 8-COMPSD/Zip Folder/Rar Folder/Subfolder with rar/Rar Folder/Content 1 inside rar.txt', \ 'Folder 8-COMPSD/Zip Folder/Rar Folder/Subfolder with rar/Rar Folder/Content 2 inside rar.txt'] assert equal_lists(t, self.fm.inspect_single_file("Folder 8-COMPSD")) is True, FILEMANAGER_ERROR_SCAN del t
def testF3(self): """ Testeo de una carpeta con archivos rar. :return: void :rtype: None """ p = Package(self.f.inspect_single_file("Folder 3"), True) if VERBOSE: print_bars_console("Testeo Folder 3") print "Archivos en forma raw:", p._print_raw_files() print "Nombre del paquete:", print p.get_package_name() print "Archivos del paquete:" p._print_file_list() # noinspection SpellCheckingInspection print "Jerarquia del paquete:" p._print_hierarchy() print "Numero de subcarpetas:", print p.get_number_of_subfolders() assert p.get_package_name() == "Folder 3", PACKAGE_TEST_ERROR_INVALID_NAME assert p.get_number_of_subfolders() == 3, PACKAGE_TEST_ERROR_COUNT_SUBFOLDERS assert p.get_number_of_elements() == 8, PACKAGE_TEST_ERROR_COUNT_FILES del p
def testBig(self): """ Testeo de un paquete grande. :return: void :rtype: None """ p = Package(self.f.inspect_single_file("Folder 5"), True) if VERBOSE: p._print_hierarchy() print_bars_console("Testeo folder 5") # Testeo general assert p.get_package_name() == "Folder 5", PACKAGE_TEST_ERROR_INVALID_NAME assert p.get_number_of_elements() == 25, PACKAGE_TEST_ERROR_COUNT_FILES assert p.get_number_of_subfolders() == 12, PACKAGE_TEST_ERROR_COUNT_FILES # Testeo de carpetas assert p.is_folder("Subfolder 2 with zip") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_folder("Subfolder 1 with zip") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_folder("Folder 1 inside subfolder 1") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_folder("Folder 2 inside subfolder 1") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_folder("Folder 3 inside subfolder 1") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_folder("Rar Folder inside Zip Folder") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_folder("Rar Folder inside Rar Folder") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_folder("Folder 1 inside folder 2 inside subfolder 1") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_folder("Folder 1 inside folder 2 inside subfolder 2") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_folder("main.java") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_folder("Content 9.txt") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_folder("") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_folder("A2.txt") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_folder("Subfolder 1") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER # Testeo de archivos assert p.is_file("Subfolder 2 with zip") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Subfolder 1 with zip") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Folder 1 inside subfolder 1") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Folder 2 inside subfolder 1") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Folder 3 inside subfolder 1") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Rar Folder inside Zip Folder") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Rar Folder inside Rar Folder") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Folder 1 inside folder 2 inside subfolder 1") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Folder 1 inside folder 2 inside subfolder 2") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Content 14.txt") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Content.txt") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Subfolder with zip") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Zip Folder") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Content 2 inside rar") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Content 1 inside rar") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Content 3 inside rar.txt") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Content 2 inside zip.txt") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("A2.txt") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Content 5.txt") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Content K.txt") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Parte1.java") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Content 11.java") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Content 2 inside rar.txt") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Content 2 inside rar.txt") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Content 1.txt") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE del p
def testValidationSubfoldered3(self): """ Test de validación con subcarpetas en donde la estructura se repite en una carpeta interna pero falla por regex. :return: void :rtype: None """ f = FileManager(DIR_DATA_TEST) f.disable_remove_on_extract() f.enable_structure_characters() v = PackageValidator() v.enable_exceptions() p = PackageFileManager(f, "Package-validation 3", True) p.enable_exception_throw() v.set_structure_directory(DIR_DATA_TEST + "STRUCTURE") # Prints estructuras a verificar if VERBOSE: print_bars_console("Testeo Package-validation 3 con STRUCTURE") p._print_hierarchy() print "" v._print_structure_hierarchy() # Se valida el paquete v.validate_package(p, VERBOSE) # Falla por regex en name_surname assert p.is_valid() is False, VALIDATOR_TEST_ERROR_VALIDATE_EMPTY_BOTH
def testPackageWithCompressedAlreadyExistsDisableExtract(self): """ Testeo de una carpeta con archivos comprimidos de igual nombre que las carpetas internas. :return: void :rtype: None """ self.f.disable_extract_if_folder_already_exists() p = PackageFileManager(self.f, "Folder 8-COMPSD", True) if VERBOSE: print_bars_console("Testeo folder 8 con archivos comprimidos de igual nombre - extracción deshabilitada") p._print_hierarchy() assert p.get_package_name() == "Folder 8-COMPSD", PACKAGE_TEST_ERROR_INVALID_NAME assert p.get_number_of_elements() == 15, PACKAGE_TEST_ERROR_COUNT_FILES assert p.get_number_of_subfolders() == 9, PACKAGE_TEST_ERROR_COUNT_SUBFOLDERS # Asserts file assert p.is_file("Zip Folder") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_file("Parte1.java") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Parte2.java") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("PartE1.java") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Content 1 inside rar.txt") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Content 1 inside rAr.txt") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Content 1.txt") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE # Asserts folder assert p.is_folder("Zip Folder") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_folder("Zip FOlder") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_folder("Rar Folder") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_folder("Zip Folder TARGET") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_folder("Zip Folder TARGEt") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER
def testArchivoInexistente(self): """ Testeo de un archivo inexistente. :return: void :rtype: None """ if VERBOSE: print_bars_console("Testeo de un archivo inexistente") print self.fm.inspect_single_file("Inexistente") assert equal_lists([], self.fm.inspect_single_file("Inexistente")) is True, FILEMANAGER_ERROR_SCAN
def testProhibido(self): """ Test de un archivo bloqueado por configuración. :return: void :rtype: None """ if VERBOSE: print_bars_console("Testeo de archivos prohibidos") print self.fm.inspect_single_file("__MACOSX") assert equal_lists([], self.fm.inspect_single_file("__MACOSX")) is True, FILEMANAGER_ERROR_SCAN
def testArchivoSingle(self): """ Test de un archivo no carpeta. :return: void :rtype: None """ if VERBOSE: print_bars_console("Testeo de un archivo no carpeta") print self.fm.inspect_single_file("ABOUT") assert equal_lists([], self.fm.inspect_single_file("ABOUT")), FILEMANAGER_ERROR_SCAN
def testRar(self): """ Testeo de un archivo rar. :return: void :rtype: None """ if VERBOSE: print_bars_console("Testeo de archivo rar") print self.fm.inspect_single_file("Rar Folder.rar") t = ['Rar Folder/Content 1 inside rar.txt', 'Rar Folder/Content 2 inside rar.txt'] assert equal_lists(t, self.fm.inspect_single_file("Rar Folder.rar")) is True, FILEMANAGER_ERROR_SCAN del t
def testF4(self): """ Testeo de una carpeta con múltiples archivos zip. :return: void :rtype: None """ p = Package(self.f.inspect_single_file("Folder 4"), True) if VERBOSE: print_bars_console("Testeo folder 4") p._print_hierarchy() assert p.get_package_name() == "Folder 4", PACKAGE_TEST_ERROR_INVALID_NAME assert p.get_number_of_elements() == 10, PACKAGE_TEST_ERROR_COUNT_FILES assert p.get_number_of_subfolders() == 4, PACKAGE_TEST_ERROR_COUNT_SUBFOLDERS assert p.is_file("Zip Folder") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_file("") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER del p
def testPackageWithFilemanager(self): """ Testeo del package el cual utiliza un filemanager. :return: void :rtype: None """ p = PackageFileManager(self.f, "Folder 4", True) if VERBOSE: print_bars_console("Testeo folder 4") p._print_hierarchy() assert p.get_package_name() == "Folder 4", PACKAGE_TEST_ERROR_INVALID_NAME assert p.get_number_of_elements() == 10, PACKAGE_TEST_ERROR_COUNT_FILES assert p.get_number_of_subfolders() == 4, PACKAGE_TEST_ERROR_COUNT_SUBFOLDERS assert p.is_file("Zip Folder") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_file("") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER del p
def testSimple(self): """ Test sencillo. :return: void :rtype: None """ p = Package(self.f.inspect_single_file("Folder 1"), True) if VERBOSE: print_bars_console("Testeo folder 1") p._print_hierarchy() print "Numero de elementos:", print p.get_number_of_elements() assert p.get_number_of_elements() == 2, PACKAGE_TEST_ERROR_COUNT_FILES assert p.get_number_of_subfolders() == 0, PACKAGE_TEST_ERROR_COUNT_SUBFOLDERS assert p.is_file("Content 3.txt") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Content 1.txt") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE del p
def testDepthFile(self): """ Testea la búsqueda de profunidad de un archivo. :return: void :rtype: None """ p = Package(self.f.inspect_single_file("Folder 9-SIM3ZIP"), True) if VERBOSE: print_bars_console("Testeo folder 9 similar a 3 con archivos zip - Busqueda de profundidad de archivos") p._print_hierarchy() assert p.get_file_depth("Zip Folder 2") == 1, PACKAGE_TEST_BAD_SEARCH_DEPTH assert p.get_file_depth("Zip Folder") == 0, PACKAGE_TEST_BAD_SEARCH_DEPTH assert p.get_file_depth("Zip Folder 3") == PACKAGE_FILE_INVALID_DEPTH, PACKAGE_TEST_BAD_SEARCH_DEPTH assert p.get_file_depth("Content A.txt") == 0, PACKAGE_TEST_BAD_SEARCH_DEPTH assert p.get_file_depth("Content C.txt") == 1, PACKAGE_TEST_BAD_SEARCH_DEPTH assert p.get_file_depth("Content E.txt") == 2, PACKAGE_TEST_BAD_SEARCH_DEPTH assert p.get_file_depth("Content Z.txt") == PACKAGE_FILE_INVALID_DEPTH, PACKAGE_TEST_BAD_SEARCH_DEPTH
def testSeguidas(self): """ Testeo de varias carpetas concatenados. :return: void :rtype: None """ p = Package(self.f.inspect_single_file("Folder 6"), True) if VERBOSE: p._print_hierarchy() print_bars_console("Testeo folder 6 - Carpetas seguidas") print "Chequeo de existencia de Hello world:", p.check_if_exist("Hello world.txt") assert p.get_number_of_subfolders() == 4, PACKAGE_TEST_ERROR_COUNT_SUBFOLDERS assert p.get_number_of_elements() == 1, PACKAGE_TEST_ERROR_COUNT_FILES assert p.is_file("Hello world.txt") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_file("Subfolder 1") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FILE assert p.is_folder("Hello world.txt") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_folder("Subfolder 1") is True, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER del p
def testCarpetaConRar(self): """ Testeo de una carpeta con un archivo rar dentro. :return: void :rtype: None """ if VERBOSE: print_bars_console("Testeo de una carpeta con un archivo rar dentro") print self.fm.inspect_single_file("Folder 3") t = ['Folder 3/Content 1.txt', \ 'Folder 3/Content 2.txt', \ 'Folder 3/Rar Folder/Content 1 inside rar.txt', \ 'Folder 3/Rar Folder/Content 2 inside rar.txt', \ 'Folder 3/Subfolder with rar/Content 1.txt', \ 'Folder 3/Subfolder with rar/Content 2.txt', \ 'Folder 3/Subfolder with rar/Rar Folder/Content 1 inside rar.txt', \ 'Folder 3/Subfolder with rar/Rar Folder/Content 2 inside rar.txt'] assert equal_lists(t, self.fm.inspect_single_file("Folder 3")) is True, FILEMANAGER_ERROR_SCAN del t
def testInexistente(self): """ Testeo de una carpeta inexistente. :return: void :rtype: None """ p = Package(self.f.inspect_single_file("Fake name")) p.generate_hierarchy() if VERBOSE: print_bars_console("Testeo de carpeta inexistente") print "Lista de archivos:", p.get_file_list() print "Nombre del paquete:", p.get_package_name() print "Numero de elementos:", p.get_number_of_elements() print "Numero de subcarpetas:", p.get_number_of_subfolders() assert p.get_number_of_elements() == 0, PACKAGE_TEST_ERROR_COUNT_FILES assert p.get_number_of_subfolders() == 0, PACKAGE_TEST_ERROR_COUNT_FILES assert p.get_package_name() == PACKAGE_NO_NAME, PACKAGE_TEST_ERROR_INVALID_NAME assert p.is_file("") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_folder("") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.check_if_exist("") is False, PACKAGE_TEST_FOUND_INEXISTENT_FILE del p
def testSeguidasEmpty(self): """ Testeo de varias carpetas concatenadas sin archivos. :return: void :rtype: None """ p = Package(self.f.inspect_single_file("Folder 6-EMPTY"), True) if VERBOSE: p._print_hierarchy() print_bars_console("Testeo folder 6 - Vacía") print "Lista de archivos:", p.get_file_list() print "Nombre del paquete:", p.get_package_name() print "Numero de elementos:", p.get_number_of_elements() print "Numero de subcarpetas:", p.get_number_of_subfolders() assert p.get_number_of_elements() == 0, PACKAGE_TEST_ERROR_COUNT_FILES assert p.get_number_of_subfolders() == 0, PACKAGE_TEST_ERROR_COUNT_FILES assert p.get_package_name() == "Folder 6-EMPTY", PACKAGE_TEST_ERROR_INVALID_NAME assert p.is_file("") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.is_folder("") is False, PACKAGE_TEST_FOUND_NOT_CORRECT_FOLDER assert p.check_if_exist("") is False, PACKAGE_TEST_FOUND_INEXISTENT_FILE del p
def testZipConCarpeta(self): """ Testeo de un archivo zip con una carpeta dentro. :return: void :rtype: None """ if VERBOSE: print_bars_console("Testeo de una carpeta con un archivo zip dentro") print self.fm.inspect_single_file("Folder 4") t = ['Folder 4/Content 1.txt', \ 'Folder 4/Content 2.txt', \ 'Folder 4/Subfolder 1/Content 1.txt', \ 'Folder 4/Subfolder 1/Content 2.txt', \ 'Folder 4/Subfolder with zip/Content 1.txt', \ 'Folder 4/Subfolder with zip/Content 2.txt', \ 'Folder 4/Subfolder with zip/Zip Folder/Content 1 inside zip.txt', \ 'Folder 4/Subfolder with zip/Zip Folder/Content 2 inside zip.txt', \ 'Folder 4/Zip Folder/Content 1 inside zip.txt', \ 'Folder 4/Zip Folder/Content 2 inside zip.txt'] assert equal_lists(t, self.fm.inspect_single_file("Folder 4")) is True, FILEMANAGER_ERROR_SCAN del t
def testFindFile(self): """ Testea la búsqueda de archivos. :return: void :rtype: None """ p = Package(self.f.inspect_single_file("Folder 6"), True) if VERBOSE: print_bars_console("Testeo folder 6 - Busqueda de ubicación de archivos") p._print_hierarchy() t = "/Subfolder 1/Subfolder 2/Subfolder 3/Subfolder 4/Hello world.txt" assert p.find_file_location("Hello world.txt") == t, PACKAGE_TEST_BAD_SEARCH_LOCATION assert p.find_file_location("main.java") == PACKAGE_FILE_NOT_FOUND, PACKAGE_TEST_BAD_SEARCH_LOCATION t = "/Subfolder 1/Subfolder 2/Subfolder 3/Subfolder 4/" assert p.find_file_location("Subfolder 4") == t, PACKAGE_TEST_BAD_SEARCH_LOCATION t = "/Subfolder 1/Subfolder 2/Subfolder 3/" assert p.find_file_location("Subfolder 3") == t, PACKAGE_TEST_BAD_SEARCH_LOCATION t = "/Subfolder 1/" assert p.find_file_location("Subfolder 1") == t, PACKAGE_TEST_BAD_SEARCH_LOCATION assert p.find_file_location("Subfolder 5") == PACKAGE_FILE_NOT_FOUND, PACKAGE_TEST_BAD_SEARCH_LOCATION del t
def testCarpetaUnica(self): """ Testeo de una carpeta sencilla sin subcarpetas. :return: void :rtype: None """ self.fm.restore_wd() if VERBOSE: print_bars_console("Testeo de carpetas únicas") print self.fm.inspect_single_file("Folder 1") t = ['Folder 1/Content 1.txt', \ 'Folder 1/Content 2.txt'] assert equal_lists(t, self.fm.inspect_single_file("Folder 1")) is True, FILEMANAGER_ERROR_SCAN if VERBOSE: print self.fm.inspect_single_file("Folder 2") t = ['Folder 2/Content 1.txt', \ 'Folder 2/Content 2.txt', \ 'Folder 2/Subfolder/Content 1.txt', \ 'Folder 2/Subfolder/Content 2.txt'] assert equal_lists(t, self.fm.inspect_single_file("Folder 2")) is True, FILEMANAGER_ERROR_SCAN del t
def testValidationSimple(): """ Test de validación simple. :return: void :rtype: None """ f = FileManager(DIR_DATA_TEST) f.disable_remove_on_extract() f.enable_structure_characters() v = PackageValidator() v.enable_exception_as_string() # Carpeta con 1 sólo archivo p = PackageFileManager(f, "Folder 10", True) p.enable_exception_throw() v.set_structure_directory(DIR_DATA_TEST + "STRUCTURE SINGLE FILE") # Prints estructuras a verificar if VERBOSE: print_bars_console("Testeo Folder 10 con STRUCTURE SINGLE FILE") p._print_hierarchy() print "" v._print_structure_hierarchy() # Se valida el paquete v.validate_package(p, VERBOSE) # Prints jerarquías de archivos if VERBOSE: print "" print_bars_console("Jerarquías de archivos válidos / no validos", 1) p._print_valid_hierachy_list(1) print "" p._print_not_valid_hierachy_list(1) print "" assert p.is_valid() is True, VALIDATOR_TEST_ERROR_VALIDATE_EMPTY_BOTH
def testValidationSubfoldered5(self): """ Test de validación con subcarpetas en donde la estructura se repite en una carpeta interna. :return: void :rtype: None """ f = FileManager(DIR_DATA_TEST) f.disable_remove_on_extract() f.enable_structure_characters() v = PackageValidator() v.enable_exceptions() p = PackageFileManager(f, "Package-validation 5", True) p.enable_exception_throw() v.set_structure_directory(DIR_DATA_TEST + "STRUCTURE 2") # Prints estructuras a verificar if VERBOSE: print_bars_console("Testeo Package-validation 5 con STRUCTURE 2") p._print_hierarchy() print "" v._print_structure_hierarchy() # Se valida el paquete v.validate_package(p, VERBOSE) p._print_validated_filelist() # Prints jerarquías de archivos if VERBOSE: print "" print_bars_console("Jerarquías de archivos válidos / no validos", 1) p._print_valid_hierachy_list(1) print "" p._print_not_valid_hierachy_list(1) print "" assert p.is_valid() is True, VALIDATOR_TEST_ERROR_VALIDATE_EMPTY_BOTH
def testFolder5(self): """ Testeo de una carpeta grande. :return: void :rtype: None """ if VERBOSE: print_bars_console("Testeo Folder 5") print self.fm.inspect_single_file("Folder 5") t = ['Folder 5/Content 1.txt', \ 'Folder 5/Content 2.txt', \ 'Folder 5/Subfolder 1/Content 3.txt', \ 'Folder 5/Subfolder 1/Content 4.txt', \ 'Folder 5/Subfolder 1/Folder 1 inside subfolder 1/Content 5.txt', \ 'Folder 5/Subfolder 1/Folder 2 inside subfolder 1/Content 6.txt', \ 'Folder 5/Subfolder 1/Folder 2 inside subfolder 1/Content 7.txt', \ 'Folder 5/Subfolder 1/Folder 2 inside subfolder 1/Folder 1 inside folder 2 inside subfolder 1/Content C.txt', \ 'Folder 5/Subfolder 1/Folder 2 inside subfolder 1/Folder 1 inside folder 2 inside subfolder 1/README.txt', \ 'Folder 5/Subfolder 1/Folder 2 inside subfolder 1/Folder 1 inside folder 2 inside subfolder 1/Subfolder 1/A1.txt', \ 'Folder 5/Subfolder 1/Folder 2 inside subfolder 1/Folder 1 inside folder 2 inside subfolder 1/Subfolder 1/A2.txt', \ 'Folder 5/Subfolder 1/Folder 2 inside subfolder 1/Folder 1 inside folder 2 inside subfolder 1/Subfolder with zip/Content K.txt', 'Folder 5/Subfolder 1/Folder 2 inside subfolder 1/Folder 1 inside folder 2 inside subfolder 1/Subfolder with zip/Content X.txt', \ 'Folder 5/Subfolder 1/Folder 2 inside subfolder 1/Folder 1 inside folder 2 inside subfolder 1/Subfolder with zip/Zip Folder/main.java', \ 'Folder 5/Subfolder 1/Folder 2 inside subfolder 1/Folder 1 inside folder 2 inside subfolder 1/Subfolder with zip/Zip Folder/Parte1.java', \ 'Folder 5/Subfolder 1/Folder 2 inside subfolder 1/Folder 1 inside folder 2 inside subfolder 1/Zip Folder/Content 1 inside zip.txt', \ 'Folder 5/Subfolder 1/Folder 2 inside subfolder 1/Folder 1 inside folder 2 inside subfolder 1/Zip Folder/Content 2 inside zip.txt', \ 'Folder 5/Subfolder 2 with zip/Content 8.txt', \ 'Folder 5/Subfolder 2 with zip/Content 9.txt', \ 'Folder 5/Subfolder 2 with zip/Zip Folder inside subfolder 2/Content 10', \ 'Folder 5/Subfolder 2 with zip/Zip Folder inside subfolder 2/Content 11.java', \ 'Folder 5/Zip Folder/Content A', \ 'Folder 5/Zip Folder/Content B.jar', \ 'Folder 5/Zip Folder/Rar Folder inside Zip Folder/Content 1 inside rar.txt', \ 'Folder 5/Zip Folder/Rar Folder inside Zip Folder/Content 2 inside rar.txt'] assert equal_lists(t, self.fm.inspect_single_file("Folder 5")) is True, FILEMANAGER_ERROR_SCAN del t
# Main test if __name__ == "__main__": # Importación de librerías # noinspection PyUnresolvedReferences from _testpath import * # @UnusedWildImport from bin.configloader import ConfigLoader from bin.utils import compare_version, get_version, print_bars_console from config import DIR_CONFIG from bin import __version__ # Arreglo de comparaciones versionDict = {1: ">", 2: "<", 0: "=="} # Se cargan las configuraciones del update print_bars_console("Cargando configuraciones") updateConfig = ConfigLoader(DIR_CONFIG, "updates.ini") label = str(updateConfig.get_value("LABEL")) web = updateConfig.get_value("WEB") header = str(updateConfig.get_value("HEADER")) print "Label a usar:", label print "Web cargada:", web print "Headers cargados:", header # Se carga la version web print_bars_console("Obteniendo version web") version = get_version(label, header, web) print "Version local:", __version__ print "Version web:", version # noinspection SpellCheckingInspection print "Comparacion version (1) Local, (2) Web ===> (1)", versionDict[compare_version(__version__, version)], "(2)"