| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- 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 **")
- _print_("\nWARNING: CLOSE ANY OPENED ACCESS PROJECT TO AVOID UNEXPECTED PROBLEMS")
- for subdir in (".\\work", ".\\results"):
- if file.fexists(subdir):
- _print_("clean "+subdir)
- file.frmdir(os.path.abspath(subdir))
-
- _print_("make dir "+subdir)
- file.fmkdir(os.path.abspath(subdir))
- _print_("unzip OpenAccess.zip in .\\work\\")
- os.system("unzip -q ..\\OpenAccess.zip -d .\\work\\")
- 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)
- # at this point, we did a complete export of project0.accdb,
- # then an import of the previously created sources in the empty_project.accdb
- # we now export the sources of empty_project.accdb to control the integrity of the newly created app
- _print_("\n** TEST RE-EXPORTS **")
- _print_("Delete .\\work\\source")
- file.frmdir(".\\work\\source")
- _print_("Export the sources from " + import_project)
- os.system( import_project + " /X test_export" )
- _print_("Verify the log file")
- result = utilities.verify_log(".\\work\\empty_project_2.log")
- if result != 0:
- sys.exit(result)
- utilities.clean_sources( ".\\work\\source\\" )
- source = ".\\work\\source"
- target = ".\\results\\source2"
- _print_("Copy {} to {}".format(source, target))
- copy_tree(source, target)
- _print_("control the result")
- result = utilities.compare_dirs( ".\\results\\source2", ".\\reference\\source" )
- if result != 0:
- sys.exit(result)
- _print_(".\\results\\source2 and .\\reference\\source are identical")
- _print_("** end **")
- sys.exit(0)
|