def testCreateAndDeleteProjectFolder(self): # avoid warning resourcewarning unclosed ssl.sslsocket due to Dropbox warnings.filterwarnings(action="ignore", message="unclosed", category=ResourceWarning) if os.name == 'posix': configFilePathName = '/storage/emulated/0/Android/data/ru.iiec.pydroid3/files/trans_file_cloud/test/dropbox_access_tst.ini' else: configFilePathName = 'D:\\Development\\Python\\trans_file_cloud\\test\\dropbox_access_tst.ini' cm = ConfigManager(configFilePathName) projectName = 'transFileCloudTestProjectToCreate' # creating a DropboxAccess on an inexisting Dropbox folder # to ensure the folder does not exist drpa = DropboxAccess(cm, projectName) self.assertRaises(NotADirectoryError, drpa.getCloudFileNameList) # now, creating the project folder drpa.createProjectFolder() # should not raise any error drpa.getCloudFileNameList() # now deleting the newly created folder so that this test can be run again drpa = DropboxAccess(cm, projectName) drpa.deleteProjectFolder() # verify the project folder was deleted self.assertRaises(NotADirectoryError, drpa.getCloudFileNameList)
def testUploadAndDeleteFilePathName(self): if os.name == 'posix': configFilePathName = '/storage/emulated/0/Android/data/ru.iiec.pydroid3/files/trans_file_cloud/test/transfiles.ini' localDir = '/storage/emulated/0/Android/data/ru.iiec.pydroid3/files/trans_file_cloud/test/testproject_3/projectdir' else: configFilePathName = 'D:\\Development\\Python\\trans_file_cloud\\test\\transfiles.ini' localDir = 'D:\\Development\\Python\\trans_file_cloud\\test\\testproject_3\\projectdir' cm = ConfigManager(configFilePathName) projectName = 'transFileCloudFilePathNameProject' # creating a DropboxAccess on an inexisting Dropbox folder # to ensure the folder does not exist drpa = DropboxAccess(cm, projectName) try: drpa.getCloudFileNameList() except NotADirectoryError: # if project folder does not exist drpa.createProjectFolder() # should not raise any error self.assertEqual([], drpa.getCloudFileNameList()) # now, uploading two files, one in the root of project dir, the other # in a project sub dir localProjectDir = cm.getProjectLocalDir(projectName) uploadFileNameProjectRoot = 'filemover_2.py' localFilePathName = localDir + sep + uploadFileNameProjectRoot drpa.uploadFilePathName(localFilePathName) uploadFileNameProjectSubdir = 'test' + sep + 'testfilemover_2.py' localFilePathName = localDir + sep + uploadFileNameProjectSubdir drpa.uploadFilePathName(localFilePathName) uploadFileNameProjectSubdirSlashDirSep = uploadFileNameProjectSubdir.replace( '\\', '/') self.assertEqual([ uploadFileNameProjectRoot, uploadFileNameProjectSubdirSlashDirSep ], drpa.getCloudFilePathNameList()) # now deleting the newly created file so that this test can be run again drpa.deleteFile(uploadFileNameProjectRoot) drpa.deleteFile(uploadFileNameProjectSubdirSlashDirSep) # should not raise any error self.assertEqual([], drpa.getCloudFilePathNameList()) drpa.deleteProjectFolder()