test.py 2.3 KB

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