""" Test for adding a single file to a bundle on the command line """ import bundle_test_helper TEST_BUNDLE_FN = "testresult.bundle.repy" TEST_FILENAMES = ['src1', 'src2', 'src3'] TEST_COPY_FILENAMES = ['src1copy', 'src2copy', 'src3copy'] # Make sure the bundle doesn't exist to test bundle creation bundle_test_helper.remove_files_from_directory([TEST_BUNDLE_FN]) bundle_test_helper.prepare_test_sourcefiles() # First create the bundle bundle_test_helper.run_program("bundler.py", ["create", TEST_BUNDLE_FN]) # Add multiple files bundle_test_helper.run_program("bundler.py", ["add", TEST_BUNDLE_FN, TEST_COPY_FILENAMES[0]]) # Now run the test script! bundle_test_helper.run_repy_program(TEST_BUNDLE_FN, [TEST_FILENAMES[0]])
""" import bundle_test_helper import repyhelper repyhelper.translate_and_import('bundle.repy') TEST_BUNDLE_FN = 'test.bundle.repy' # Make sure the bundle doesn't exist to test bundle creation bundle_test_helper.remove_files_from_directory([TEST_BUNDLE_FN]) TEST_STRING = 'this is a test string' TEST_STRING_FN = 'teststring' bundle = bundle_Bundle(TEST_BUNDLE_FN, 'w') bundle.add_string(TEST_STRING_FN, TEST_STRING) bundle.close() # Make sure the added file is inside the bundle bundle = bundle_Bundle(TEST_BUNDLE_FN, 'r') if not TEST_STRING_FN in bundle.list(): print "Added string not found when listing bundle contents" # Make sure added file matches original file contents added_file_contents = bundle.extract_to_string(TEST_STRING_FN) if added_file_contents != TEST_STRING: print "Added string contents does not match string contents" # Now run the test script! bundle_test_helper.run_repy_program(TEST_BUNDLE_FN)
""" Test the extracting of all files in a bundle through the API. """ import bundle_test_helper import repyhelper repyhelper.translate_and_import('bundle.repy') TEST_BUNDLE_FN = 'test_readonly.bundle.repy' FILENAMES = ['src1', 'src2', 'src3'] # Make sure the extracted files don't exist bundle_test_helper.remove_files_from_directory([FILENAMES]) # src1copy ... src3copy is extracted bundle = bundle_Bundle(TEST_BUNDLE_FN, 'r') bundle.extract_all() bundle.close() # Check that the extracted files make sense bundle_test_helper.run_repy_program('testscript.repy', FILENAMES)
""" Test for creating bundles from an existing on the command line """ import bundle_test_helper TEST_SRC_FN = "testscript.repy" TEST_BUNDLE_FN = "testresult.bundle.repy" # Make sure the bundle doesn't exist to test bundle creation bundle_test_helper.remove_files_from_directory([TEST_BUNDLE_FN]) bundle_test_helper.run_program("bundler.py", ["create", TEST_SRC_FN, TEST_BUNDLE_FN]) # Now run the test script! bundle_test_helper.run_repy_program(TEST_BUNDLE_FN)
""" Test the extracting of a single file in a bundle through the command line. """ import bundle_test_helper TEST_BUNDLE_FN = 'test_readonly.bundle.repy' TEST_FILENAMES = ['src1', 'src2', 'src3'] TEST_COPY_FILENAMES = ['src1copy', 'src2copy', 'src3copy'] # Make sure the bundle doesn't exist to test bundle creation bundle_test_helper.remove_files_from_directory(TEST_COPY_FILENAMES) bundle_test_helper.run_program("bundler.py", ["extract", TEST_BUNDLE_FN, TEST_COPY_FILENAMES[0]]) bundle_test_helper.run_repy_program('testscript.repy', [TEST_FILENAMES[0]])
import repyhelper repyhelper.translate_and_import('bundle.repy') TEST_BUNDLE_FN = 'test.bundle.repy' ADD_FILENAMES = ['src1', 'src2', 'src3'] # Make sure the bundle doesn't exist to test bundle creation bundle_test_helper.remove_files_from_directory([TEST_BUNDLE_FN]) bundle = bundle_Bundle(TEST_BUNDLE_FN, 'w') bundle.add_files(ADD_FILENAMES) bundle.close() # Verification step bundle = bundle_Bundle(TEST_BUNDLE_FN, 'r') for addedfile in ADD_FILENAMES: # Make sure the added files are inside the bundle if not addedfile in bundle.list(): print "Added file not found when listing bundle contents" # Make sure added files matches original contents added_file_contents = bundle.extract_to_string(addedfile) if added_file_contents != open(addedfile).read(): print "Added file contents does not match file contents" bundle.close() # Now run the test script! bundle_test_helper.run_repy_program(TEST_BUNDLE_FN, ADD_FILENAMES)
repyhelper.translate_and_import('bundle.repy') TEST_BUNDLE_FN = 'test.bundle.repy' ADD_FILENAMES = ['src1', 'src2', 'src3'] # Make sure the bundle doesn't exist to test bundle creation bundle_test_helper.remove_files_from_directory([TEST_BUNDLE_FN]) bundle = bundle_Bundle(TEST_BUNDLE_FN, 'w') bundle.add_files(ADD_FILENAMES) bundle.close() # Verification step bundle = bundle_Bundle(TEST_BUNDLE_FN, 'r') for addedfile in ADD_FILENAMES: # Make sure the added files are inside the bundle if not addedfile in bundle.list(): print "Added file not found when listing bundle contents" # Make sure added files matches original contents added_file_contents = bundle.extract_to_string(addedfile) if added_file_contents != open(addedfile).read(): print "Added file contents does not match file contents" bundle.close() # Now run the test script! bundle_test_helper.run_repy_program(TEST_BUNDLE_FN, ADD_FILENAMES)
""" Test the extracting of a single file in a bundle through the command line. """ import bundle_test_helper TEST_BUNDLE_FN = 'test_readonly.bundle.repy' TEST_FILENAMES = ['src1', 'src2', 'src3'] TEST_COPY_FILENAMES = ['src1copy', 'src2copy', 'src3copy'] # Make sure the bundle doesn't exist to test bundle creation bundle_test_helper.remove_files_from_directory(TEST_COPY_FILENAMES) bundle_test_helper.run_program( "bundler.py", ["extract", TEST_BUNDLE_FN, TEST_COPY_FILENAMES[0]]) bundle_test_helper.run_repy_program('testscript.repy', [TEST_FILENAMES[0]])