예제 #1
0
def test_broker_functions(broker):

    initstring = "--broker="
    identifier = h.helicsBrokerGetIdentifier(broker)
    initstring = initstring + identifier
    initstring = initstring + " --broker_address"
    address = h.helicsBrokerGetAddress(broker)
    initstring = initstring + address
예제 #2
0
def test_broker_functions(broker):

    initstring = "--broker="
    status, identifier = h.helicsBrokerGetIdentifier(broker)
    assert status == 0
    initstring = initstring + identifier
    initstring = initstring + " --broker_address"
    status, address = h.helicsBrokerGetAddress(broker)
    assert status == 0
    initstring = initstring + address
예제 #3
0
def test_broker():
    broker = createBroker(1)
    initstring = "--broker="
    identifier = h.helicsBrokerGetIdentifier(broker)
    initstring = initstring + identifier
    initstring = initstring + " --broker_address "
    address = h.helicsBrokerGetAddress(broker)
    initstring = initstring + address
    assert initstring == "--broker=mainbroker --broker_address tcp://127.0.0.1:23404"
    destroyBroker(broker)
예제 #4
0
def test_other_tests_broker_creation():

    argv = ["--root"]

    brk = h.helicsCreateBrokerFromArgs("zmq", "gbrokerc", argv)
    assert h.helicsBrokerGetIdentifier(brk) == "gbrokerc"

    with pt.raises(h.HelicsException):
        argv.append("--log-level=what_logs?")
        brk2 = h.helicsCreateBrokerFromArgs("zmq", "gbrokerc", argv)

    h.helicsBrokerDisconnect(brk)
예제 #5
0
def test_broker_api():
    assert h.helicsIsCoreTypeAvailable("zmq") == 1
    broker1 = h.helicsCreateBroker("zmq", "broker1",
                                   "--federates 3 --loglevel 1")
    broker2 = h.helicsBrokerClone(broker1)
    address_string = h.helicsBrokerGetAddress(broker1)
    assert "tcp://127.0.0.1:23404" in address_string
    assert "broker1" in h.helicsBrokerGetIdentifier(broker1)
    err = h.helicsErrorInitialize()
    h.helicsErrorClear(err)
    assert err.error_code == 0
    assert h.ffi.string(err.message).decode() == ""
    assert h.helicsBrokerIsValid(broker1) == 1
    assert h.helicsBrokerIsConnected(broker1) == 1
    h.helicsBrokerDisconnect(broker1)
    assert h.helicsBrokerIsConnected(broker1) == 0
    h.helicsBrokerDisconnect(broker2)
    h.helicsBrokerFree(broker1)
    h.helicsBrokerFree(broker2)
    h.helicsCloseLibrary()