def test_GEToneTextSecureBox(): from create import CREATE from put import PUT from get import GET print 'testing GET from secure box with messages' CREATE('test_GEToneTextSecureBox', 0) PUT('test_GEToneTextSecureBox', 'message test_GEToneTextSecureBox') assert GET('test_GEToneTextSecureBox', 0) == 'OK' assert GET('test_GEToneTextSecureBox', 0) == ('ERROR', 'Box is empty')
def parseArgs(): if len(sys.argv) < 2: usage() if sys.argv[1] == 'PUT' and len(sys.argv) == 5: print(PUT(sys.argv[2], sys.argv[3], sys.argv[4])) elif sys.argv[1] == 'MKDIR' and len(sys.argv) == 4: print(MKDIR(sys.argv[2], sys.argv[3])) elif sys.argv[1] == 'LS' and len(sys.argv) == 4: LS(sys.argv[2], sys.argv[3]) elif sys.argv[1] == 'LS' and len(sys.argv) == 5: LS(sys.argv[2], sys.argv[3], sys.argv[4]) elif sys.argv[1] == 'GET' and len(sys.argv) == 5: GET(sys.argv[2], sys.argv[3], sys.argv[4]) elif sys.argv[1] == 'GET' and len(sys.argv) == 6: GET(sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5]) elif sys.argv[1] == 'CP' and len(sys.argv) == 5: print(CP(sys.argv[2], sys.argv[3], sys.argv[4])) elif sys.argv[1] == 'RM' and len(sys.argv) == 4: print(RM(sys.argv[2], sys.argv[3])) elif sys.argv[1] == 'MV' and len(sys.argv) == 5: print(MV(sys.argv[2], sys.argv[3], sys.argv[4])) else: usage()
def test_GETsecureEmptyBox(): from create import CREATE from get import GET print 'testing GET from a secure empty box with wrong argument' CREATE('test_GETsecureEmptyBox', 1) assert GET('test_GETsecureEmptyBox', 1) == ('ERROR', 'Box is empty')
def test_GETwrongSecure(): from create import CREATE from get import GET print 'testing GET from a secure box with wrong argument' CREATE('test_GETwrongSecureBox', 1) assert GET('testGETwrongSecureBox', 2) == ('ERROR', 'Invalid user input')
def test_GETemptyBox(): from create import CREATE from get import GET print 'testing GET from empty box' CREATE('test_GETemptybox', 0) assert GET('test_GETemptybox', 0) == ('ERROR', 'Box is empty')
def test_GETnoSuchBox(): from get import GET print 'testing GET from unexisting box' assert GET('testGETnoSuchBox', 0) == ('ERROR', 'Box not found')
MKDIR(fs, curr_dirpath) end = datetime.now() time_res = formatTimeDelta(start, end) mf.write("{}, {}\n".format(k, time_res)) if not k % test_incs: # time put start = datetime.now() put_loc = '{}/{}'.format(curr_dirpath, file_to_put) PUT(fs, file_to_put, put_loc) end = datetime.now() time_res = formatTimeDelta(start, end) pf.write("{}, {}\n".format(k, time_res)) # untimed GET to load into cache GET(fs, put_loc, get_path) # time get start = datetime.now() GET(fs, put_loc, get_path) end = datetime.now() time_res = formatTimeDelta(start, end) gf.write("{}, {}\n".format(k, time_res)) print(k) curr_dirpath += dirname mf.close() pf.close() gf.close()