Ejemplo n.º 1
0
def t06(home, w):
    pretty = '%s t06' % __file__
    print(pretty)

    meta = w.flocker_push_string('hej hej',     dst='hej.txt')
    meta = w.flocker_push_string('hello hello', dst='hello.txt')

    w = Workspace(home=home)
    with open(os.path.join(w.path, 'hola.txt'), 'w') as f:
        f.write('hola hola')

    # only need to provide key in first call to the second workspace
    meta = w.flocker_push_file('hola.txt', key=meta['key'])
    meta = w.flocker_push_string('nihao nihao', dst='hello.txt')

    #verify all the file is located in the same remote dir
    w.ftpclient.ftp.cwd(meta['key'])
    lines = w.ftpclient.list_remote_files()
    expectedfile = ['hej.txt', 'hello.txt', 'hola.txt']
    if lines != expectedfile:
        print('FAIL %s: could not push file from different workspace: %s' % (pretty, str(expectedfile)))
        return False

    w.flocker_get_file('hello.txt', 'test_remote.txt')
    remote_txt = w.cat('test_remote.txt')
    expectedtxt = 'hello hellonihao nihao'

    if expectedtxt != remote_txt:
        print("FAIL %s: could not push string from different workspace to same file" % (pretty, expectedtxt))
        return False

    return True
Ejemplo n.º 2
0
def t07(home, w):
    pretty = '%s t07' % __file__
    print(pretty)

    w = Workspace(home=home)
    custom_key = 'friendly_prefix_%s' % time.strftime("%H:%M:%S")
    # test custome_key not existed
    meta = w.flocker_push_string('hej hej', dst='hej.txt')
    try:
        w.flocker_initial(existing_key=custom_key)
    except Exception, e:
        if 'Could not access friendly_prefix' not in str(e):
            return False