Esempio n. 1
0
def config_db(request):
    filename = local_config.CONFIG_PATH
    with file(filename, 'a'):
        os.utime(filename, None)

    name = TESTDB
    url = 'https://localhost:2223'
    path = '/home/myself/cozyfiles'
    db_login = '******'
    db_password = '******'
    dbutils.create_db(name)
    dbutils.create_db_user(name, db_login, db_password)
    local_config.add_config(name, url, path, db_login, db_password)
    db = dbutils.get_db(name)
    dbutils.init_database_views(name)

    binary = {
       '_id': BINARY_ID,
        'docType': 'Binary',
    }
    db.save(binary)
    db.put_attachment(binary, open('./file_test.txt'), 'file')

    testfile = {
        '_id': FILE_ID,
        'docType': 'File',
        'path': '/tests',
        'name': 'file_test.txt',
        'binary': { 'file': { 'id': BINARY_ID } }
    }
    db.save(testfile)

    def fin():
        dbutils.remove_db(name)
    request.addfinalizer(fin)
Esempio n. 2
0
def config_db(request):
    filename = local_config.CONFIG_PATH
    with file(filename, 'a'):
        os.utime(filename, None)

    name = TESTDB
    url = 'https://localhost:2223'
    path = '/home/myself/cozyfiles'
    db_login = '******'
    db_password = '******'
    dbutils.create_db(name)
    local_config.add_config(name, url, path, db_login, db_password)
Esempio n. 3
0
def config_db(request):
    # Create config folder and YAML file if not exist
    if not os.path.isdir(local_config.CONFIG_FOLDER):
        os.mkdir(local_config.CONFIG_FOLDER)
    with open(local_config.CONFIG_PATH, 'a'):
        os.utime(local_config.CONFIG_PATH, None)

    name = TESTDB
    url = 'https://localhost:2223'
    path = '/home/myself/cozyfiles'
    db_login = '******'
    db_password = '******'
    dbutils.create_db(name)
    local_config.add_config(name, url, path, db_login, db_password)
Esempio n. 4
0
def config_db(request):
    filename = local_config.CONFIG_PATH
    with file(filename, 'a'):
        os.utime(filename, None)

    name = TESTDB
    url = 'https://localhost:2223'
    path = '/home/myself/cozyfiles'
    db_login = '******'
    db_password = '******'
    dbutils.remove_db(name)
    dbutils.create_db(name)
    dbutils.create_db_user(name, db_login, db_password)
    local_config.add_config(name, url, path, db_login, db_password)
    db = dbutils.get_db(name)
    dbutils.init_database_views(name)

    device = {
        '_id': uuid4().hex,
        'docType': 'Device',
        'login': TESTDB,
        'url': 'http://',
        'password': TESTDB,
    }
    db.save(device)

    binary = {
       '_id': BINARY_ID,
        'docType': 'Binary',
    }
    db.save(binary)
    db.put_attachment(binary, open('./file_test.txt'), 'file')

    create_file(db, '', 'file_test.txt')
    create_file(db, '/A', 'test.sh')
    create_folder(db, '', 'A')

    couchmount.unmount(local_config.MOUNT_FOLDER)
    time.sleep(1)
    couchmount.mount(name, local_config.MOUNT_FOLDER)
    time.sleep(2)

    def fin():
        pass
        #couchmount.unmount(local_config.MOUNT_FOLDER)
        #time.sleep(10)
        #dbutils.remove_db(name)
    request.addfinalizer(fin)