def test07_FtpExporterSaveReadFromProject(self): """Test saving and restoring FTP exporter settings in project""" e = FtpExporter() e.host = 'geocities.com' e.username = '******' e.port = 123 e.remote_folder = 'test_folder' e.writeToProject() restored = FtpExporter() restored.readFromProject() self.assertEqual(restored.host, 'geocities.com') self.assertEqual(restored.username, 'sup3Raw3s0m64') self.assertEqual(restored.remote_folder, 'test_folder') self.assertEqual(restored.port, 123)
def test10_FtpUploadSubfolder(self): e = FtpExporter() e.host = 'localhost' e.port = TEST_PORT e.username = '******' e.password = '******' # copy some files to export directory export_folder = e.exportDirectory() try: os.makedirs(export_folder) except Exception: self.assertTrue(False, 'could not create export directory') out_file = os.path.join(export_folder, 'index.html') with open(out_file, 'w') as i: i.write('test') sub_folder = os.path.join(export_folder, 'sub') try: os.makedirs(sub_folder) except Exception: self.assertTrue(False, 'could not create export directory') sub_folder_out_file = os.path.join(sub_folder, 'index.html') with open(sub_folder_out_file, 'w') as i: i.write('test2') result = WriterResult() result.index_file = out_file result.folder = export_folder e.postProcess(result) expected_index_file = os.path.join(FTP_USER_FOLDER, 'public_html', 'index.html') self.assertTrue(os.path.exists(expected_index_file)) f = open(expected_index_file, 'r') content = f.readlines() f.close() self.assertEqual(content, ['test']) expected_sub_folder_index_file = os.path.join(FTP_USER_FOLDER, 'public_html', 'sub', 'index.html') self.assertTrue(os.path.exists(expected_sub_folder_index_file)) f = open(expected_sub_folder_index_file, 'r') content = f.readlines() f.close() self.assertEqual(content, ['test2'])
def test10_FtpUploadSubfolder(self): e = FtpExporter() e.host = 'localhost' e.port = TEST_PORT e.username = '******' e.password = '******' # copy some files to export directory export_folder = e.exportDirectory() try: os.makedirs(export_folder) except: self.assertTrue(False, 'could not create export directory') out_file = os.path.join(export_folder, 'index.html') with open(out_file, 'w') as i: i.write('test') sub_folder = os.path.join(export_folder, 'sub') try: os.makedirs(sub_folder) except: self.assertTrue(False, 'could not create export directory') sub_folder_out_file = os.path.join(sub_folder, 'index.html') with open(sub_folder_out_file, 'w') as i: i.write('test2') result = WriterResult() result.index_file = out_file result.folder = export_folder e.postProcess(result) expected_index_file = os.path.join( FTP_USER_FOLDER, 'public_html', 'index.html') self.assertTrue(os.path.exists(expected_index_file)) f = open(expected_index_file, 'r') content = f.readlines() f.close() self.assertEqual(content, ['test']) expected_sub_folder_index_file = os.path.join( FTP_USER_FOLDER, 'public_html', 'sub', 'index.html') self.assertTrue(os.path.exists(expected_sub_folder_index_file)) f = open(expected_sub_folder_index_file, 'r') content = f.readlines() f.close() self.assertEqual(content, ['test2'])