Exemplo n.º 1
0
def t13(HOME):
    pretty = '%s t13' % __file__
    print(pretty)

    path = os.path.join(HOME.path, '.ave', 'config', 'workspace.json')
    with open(path, 'w') as f:
        json.dump({
            'root': '~',
            'tools': {
                'ls': '/bin/ls'
            },
            'flocker': FLOCKER
        }, f)
    config = Workspace.load_config(path, HOME.path)
    profile = WorkspaceProfile(config)

    if not profile.match({'type': 'workspace'}):
        print('FAIL %s: generic match failed' % pretty)
        return False

    if not profile.match({'type': 'workspace', 'tools': ['ls']}):
        print('FAIL %s: tools match failed' % pretty)
        return False

    workspace = Workspace('foobar', home=HOME.path)
    if not workspace.get_profile().match(profile):
        print('FAIL %s: non-uid match failed: %s' % (pretty, profile))
        return False

    if not workspace.get_profile().match({
            'type': 'workspace',
            'uid': 'foobar'
    }):
        print('FAIL %s: uid match failed: %s' % pretty)
        return False

    return True
Exemplo n.º 2
0
    except OSError, e:
        if e.errno != errno.EEXIST:
            raise Exception('could not create directory at %s: %s' %
                            (HOME.path, str(e)))

    path = os.path.join(HOME.path, '.ave', 'config', 'workspace.json')
    with open(path, 'w') as f:
        json.dump({'root': '~/$HOME', 'tools': {}, 'flocker': FLOCKER}, f)

    try:
        w2 = Workspace(uid='something', home=HOME.path)
    except Exception, e:
        print('FAIL %s: Workspace.__init__() failed: %s' % (pretty, str(e)))
        return

    value = w2.get_profile()['root']
    if value != '%s/%s' % (HOME.path, HOME.path):
        print('FAIL %s: wrong expansion: %s' % (pretty, value))
        return

    return True


# check that Workspace.run() refuses to run tools that are not in the "tools"
# configuration section
@smoke
@setup()
def t10(HOME):
    pretty = '%s t10' % __file__
    print(pretty)