from distutils.dir_util import copy_tree import os import sys import file import utilities def _print_(*args): print(*args) sys.stdout.flush() _print_("\n** PREPARATION **") if not file.fexists("..\\OpenAccess.accda"): _print_("unzip OpenAccess.zip in .\\") os.system("unzip -q ..\\OpenAccess.zip -d .\\") for subdir in (".\\work", ".\\results"): if file.fexists(subdir): _print_("clean "+subdir) file.frmdir(os.path.abspath(subdir)) else: _print_("make dir "+subdir) file.fmkdir(os.path.abspath(subdir)) for zipped_file in ("project0.zip", "db.zip", "empty_project.zip"): _print_("unzip .\\initial\\{} to .\\work".format(zipped_file)) os.system("unzip -q .\\initial\\{} -d .\\work".format(zipped_file)) utilities.clean_sources(".\\reference\\source") _print_("\n** TEST EXPORT **") accdb_path = ".\\work\\project0.accdb" _print_("Export the sources from " + accdb_path) os.system( accdb_path + " /X test_export" ) _print_("Verify the log file") result = utilities.verify_log(".\\work\\project0_1.log") if result != 0: sys.exit(result) utilities.clean_sources( ".\\work\\source\\" ) zipped_project0 = ".\\work\\project0.zip" _print_("control existence of " + zipped_project0) if not file.fexists( zipped_project0 ): _print_( zipped_project0 +" does not exist" ) sys.exit(1) source = ".\\work\\source" target = ".\\results\\source1" _print_("Copy {} to {}".format(source, target)) copy_tree(source, target) _print_("control the result") result = utilities.compare_dirs( ".\\results\\source1", ".\\reference\\source" ) if result != 0: sys.exit(result) _print_(".\\results\\source1 and .\\reference\\source are identical") _print_("\n** TEST IMPORTS **") import_project = ".\\work\\empty_project.accdb" _print_("Import .\\work\\sources in " + import_project) os.system(import_project + " /X test_import") _print_("Verify the log file") result = utilities.verify_log(".\\work\\empty_project_1.log") if result != 0: sys.exit(result) _print_("copy {} to {}".format(import_project, ".\\results\\empty_project_updated.accdb")) file.fcopy(import_project, ".\\results\\empty_project_updated.accdb") _print_("control existence of backup") if not file.fexists(import_project + ".old"): _print_(import_project + ".old do not exist") sys.exit(1) _print_("** end **") sys.exit(0)