| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- from distutils.dir_util import copy_tree
- import os
- import sys
- import compare
- import export
- import file
- def clean_sources(sources_path):
- print("Clean the sources")
- # remove the source code of test module and macros
- for file_path in ("modules\\test_methods.bas",
- "macros\\test_export.bas",
- "macros\\test_import.bas"):
- os.remove( file.fjoin(sources_path, file_path) )
- print("\n** PREPARATION **")
- if not file.fexists("..\\OpenAccess.accda"):
- print("unzip OpenAccess.zip in ..\\")
- os.system("unzip ..\\OpenAccess.zip -d ..\\")
- for subdir in (".\\work", ".\\results"):
- if file.fexists(subdir):
- print("clean "+subdir)
- file.frmdir(subdir)
- else:
- print("make dir "+subdir)
- file.fmkdir(subdir)
- for zipped_file in ("project0.zip", "db.zip", "empty_project.zip"):
- print("unzip .\\initial\\{} to .\\work".format(zipped_file))
- os.system("unzip .\\initial\\{} -d .\\work".format(zipped_file))
- 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" )
- 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 = compare.compare_dirs( ".\\results\\source1", ".\\reference\\source" )
- if result != 0:
- sys.exit(result)
- print("\n** TEST IMPORTS **")
- result_count = 1
- for import_project in (".\\work\\empty_project.accdb", ".\\work\\project0.accdb"):
- print("Import .\\work\\sources in " + import_project)
- os.system(import_project + " /X test_import")
-
- result_count += 1
- print("copy {} to {}".format(import_project, ".\\results\\result{}.accdb".format(result_count)))
- file.fcopy(import_project, ".\\results\\result{}.accdb".format(result_count))
-
- print("control existence of backup")
- if not file.fexists(import_project + ".old"):
- print(import_project + ".old do not exist")
- sys.exit(1)
-
- print("** TEST RESULTS **")
- for id_result in range(2, result_count + 1):
-
- resulting_accdb = ".\\results\\result{}.accdb".format(id_result)
- print("Export " + resulting_accdb)
- os.system(resulting_accdb + " /X test_export")
- print("rename .\\results\\source to .\\results\\source{}".format(id_result))
- os.rename(".\\results\\source", ".\\results\\source{}".format(id_result))
- print("Control the result")
- compare.compare_dirs( ".\\results\\source{}".format(id_result), ".\\reference\\source")
- print("** end **")
- sys.exit(0)
|