test.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. from distutils.dir_util import copy_tree
  2. import os
  3. import sys
  4. import file
  5. import utilities
  6. print("\n** PREPARATION **")
  7. if not file.fexists("..\\OpenAccess.accda"):
  8. print("unzip OpenAccess.zip in .\\work")
  9. os.system("unzip -q ..\\OpenAccess.zip -d .\\work")
  10. for subdir in (".\\work", ".\\results"):
  11. if file.fexists(subdir):
  12. print("clean "+subdir)
  13. file.frmdir(os.path.abspath(subdir))
  14. else:
  15. print("make dir "+subdir)
  16. file.fmkdir(os.path.abspath(subdir))
  17. for zipped_file in ("project0.zip", "db.zip", "empty_project.zip"):
  18. print("unzip .\\initial\\{} to .\\work".format(zipped_file))
  19. os.system("unzip -q .\\initial\\{} -d .\\work".format(zipped_file))
  20. utilities.clean_sources(".\\reference\\source")
  21. print("\n** TEST EXPORT **")
  22. accdb_path = ".\\work\\project0.accdb"
  23. print("Export the sources from " + accdb_path)
  24. os.system( accdb_path + " /X test_export" )
  25. print("Verify the log file")
  26. result = utilities.verify_log(".\\work\\project0_1.log")
  27. if result != 0:
  28. sys.exit(result)
  29. utilities.clean_sources( ".\\work\\source\\" )
  30. zipped_project0 = ".\\work\\project0.zip"
  31. print("control existence of " + zipped_project0)
  32. if not file.fexists( zipped_project0 ):
  33. print( zipped_project0 +" does not exist" )
  34. sys.exit(1)
  35. source = ".\\work\\source"
  36. target = ".\\results\\source1"
  37. print("Copy {} to {}".format(source, target))
  38. copy_tree(source, target)
  39. print("control the result")
  40. result = utilities.compare_dirs( ".\\results\\source1", ".\\reference\\source" )
  41. if result != 0:
  42. sys.exit(result)
  43. print(".\\results\\source1 and .\\reference\\source are identical")
  44. print("\n** TEST IMPORTS **")
  45. import_project = ".\\work\\empty_project.accdb"
  46. print("Import .\\work\\sources in " + import_project)
  47. os.system(import_project + " /X test_import")
  48. print("Verify the log file")
  49. result = utilities.verify_log(".\\work\\empty_project_1.log")
  50. if result != 0:
  51. sys.exit(result)
  52. print("copy {} to {}".format(import_project, ".\\results\\empty_project_updated.accdb"))
  53. file.fcopy(import_project, ".\\results\\empty_project_updated.accdb")
  54. print("control existence of backup")
  55. if not file.fexists(import_project + ".old"):
  56. print(import_project + ".old do not exist")
  57. sys.exit(1)
  58. print("** end **")
  59. sys.exit(0)