예제 #1
0
def test():
    import pyre

    # get the pyre executive
    executive = pyre.executive
    # gain access to the configurator
    c = executive.configurator
    # and the nameserver
    ns = executive.nameserver

    # attempt to request a node that doesn't exist yet
    try:
        ns["sample.user.name"]
        assert False
    except ns.UnresolvedNodeError:
        pass

    # this is the node that we build out of the configuration
    try:
        ns["sample.user.byline"]
        assert False
    except ns.UnresolvedNodeError:
        pass
    # so define it
    ns["sample.user.byline"] = "{sample.user.name} -- {sample.user.email}"

    # load a configuration file
    pyre.loadConfiguration("sample.pml")

    # report any errors
    errors = executive.errors
    if errors and executive.verbose:
        count = len(errors)
        s = '' if count == 1 else 's'
        print(' ** during configuration: {} error{}:'.format(len(errors), s))
        for error in errors:
            print(' -- {}'.format(error))
    # ns.dump()

    # try again
    assert ns["sample.user.name"] == "michael a.g. aïvázis"
    assert ns["sample.user.email"] == "*****@*****.**"
    assert ns["sample.user.affiliation"] == "orthologue"
    # and the local one
    assert ns[
        "sample.user.byline"] == "michael a.g. aïvázis -- [email protected]"

    # make a change
    ns["sample.user.affiliation"] = "orthologue"
    ns["sample.user.email"] = "*****@*****.**"
    # check
    assert ns["sample.user.affiliation"] == "orthologue"
    assert ns[
        "sample.user.byline"] == "michael a.g. aïvázis -- [email protected]"

    # all good
    return executive
예제 #2
0
def test():
    import pyre

    # get the pyre executive
    executive = pyre.executive
    # gain access to the configurator
    c = executive.configurator
    # and the nameserver
    ns = executive.nameserver

    # attempt to request a node that doesn't exist yet
    try:
        ns["sample.user.name"]
        assert False
    except ns.UnresolvedNodeError:
        pass

    # this is the node that we build out of the configuration
    try:
        ns["sample.user.byline"]
        assert False
    except ns.UnresolvedNodeError:
        pass
    # so define it
    ns["sample.user.byline"] = "{sample.user.name} -- {sample.user.email}"

    # load a configuration file
    pyre.loadConfiguration("sample.pfg")

    # report any errors
    errors = executive.errors
    if errors and executive.verbose:
        count = len(errors)
        s = '' if count == 1 else 's'
        print(' ** during configuration: {} error{}:'.format(len(errors), s))
        for error in errors:
            print(' -- {}'.format(error))
    # ns.dump()

    # try again
    assert ns["sample.user.name"] == "michael a.g. aïvázis"
    assert ns["sample.user.email"] == "*****@*****.**"
    assert ns["sample.user.affiliation"] == "orthologue"
    # and the local one
    assert ns["sample.user.byline"] == "michael a.g. aïvázis -- [email protected]"

    # make a change
    ns["sample.user.affiliation"] = "orthologue"
    ns["sample.user.email"] = "*****@*****.**"
    # check
    assert ns["sample.user.affiliation"] == "orthologue"
    assert ns["sample.user.byline"] == "michael a.g. aïvázis -- [email protected]"

    # all good
    return executive
예제 #3
0
def test():
    import pyre

    # gain access to the configurator
    cfg = pyre.executive.configurator
    # load a configuration file
    pyre.loadConfiguration("sample.pml")
    cfg["sample.user.name"] = "Joe Applegate"
    # get a configuration node
    node = cfg.resolve(name="sample.user.name")
    node.dump()

    return
예제 #4
0
def test():
    # access the framework
    import pyre

    # access the nameserver
    ns = pyre.executive.nameserver
    # and the fileserver
    fs = pyre.executive.fileserver

    # load the configuration file
    pyre.loadConfiguration('vfs:{}/sample.cfg'.format(fs.STARTUP_DIR))

    # verify that the configuration settings were read properly
    assert ns["package.home"] == "home"
    assert ns["package.prefix"] == "prefix"
    assert ns["package.user.name"] == "michael a.g. aïvázis"
    assert ns["package.user.email"] == "*****@*****.**"
    assert ns["package.user.affiliation"] == "orthologue"

    # all done
    return