def test_parent_child_relationships_in_file_system(self): # fetch the root FileSystemSnapshot object, grab its children path = FileSystemHelper.convertedPath('%AA/TextEdit.app/Contents') root = self.p.session.query(FileSystemSnapshot).filter( FileSystemSnapshot.abs_path.like(path)).one() self.assertTrue(root is not None) children = root.children for child in children: logger.info("{0}".format(child))
def test_drive_spec_and_path_splitting(self): """ Checks that splitting out the drive paths works as expected """ test_data = [( '/', ['/'], ), ( '/Applications', ['/', 'Applications'], ), ('/Users/john/something', ['/', 'Users', 'john', 'something'])] for path, expected in test_data: parts = FileSystemHelper.splitPath(path) drive = parts[0] self.assertTrue(FileSystemHelper.isDriveSpec(drive), "this isn't a drive spec: {}".format(drive)) self.assertEqual(len(parts), len(expected)) self.assertEqual(parts, expected)
def test_find_deleted_directory(self): self.builder.del_dir("AA/TextEdit.app/Contents/Frameworks") self.mergeScan() ms = self.p.session.query(FileSystemMerge).filter( FileSystemMerge.abs_path.like('%Frameworks')).one() self.assertTrue( ms.abs_path.endswith( FileSystemHelper.convertedPath( "AA/TextEdit.app/Contents/Frameworks"))) self.assertEqual(PersistentScanningState.ITEM_DELETED, ms.flags) self.assertEqual(Qt.Unchecked, ms.checked)
def test_list_external_disks_mac(self): exts = FileSystemHelper.attachedExternalDriveNames() logger.info("External disks are: {0}".format(exts))
def test_is_drive_spec_unicode(self): """Makes sure that both unicode and ASCII drive specs can be detected by the FileSystemHelper""" nonUnicodeDriveSpec = "/" unicodeDriveSpec = u"/" self.assertTrue(FileSystemHelper.isDriveSpec(nonUnicodeDriveSpec)) self.assertTrue(FileSystemHelper.isDriveSpec(unicodeDriveSpec))