Beispiel #1
0
def gateway_timeout_sim():
    config = BonsaiClientConfig()
    config.server = "http://127.0.0.1:9000"
    config.workspace = "gatewaytimeout"
    config.access_key = "1111"
    sim = MinimalSim(config)
    return sim
Beispiel #2
0
def unavailable_sim():
    config = BonsaiClientConfig()
    config.server = "http://127.0.0.1:9000"
    config.workspace = "unavailable"
    config.access_key = "1111"
    sim = MinimalSim(config)
    return sim
Beispiel #3
0
def forbidden_sim():
    config = BonsaiClientConfig()
    config.server = "http://127.0.0.1:9000"
    config.workspace = "forbidden"
    config.access_key = "1111"
    sim = MinimalSim(config)
    return sim
Beispiel #4
0
def unregister_event_sim():
    config = BonsaiClientConfig()
    config.server = "http://127.0.0.1:9000"
    config.workspace = "unregisterevent"
    config.access_key = "1111"
    sim = MinimalSim(config)
    return sim
Beispiel #5
0
def internal_server_err_sim():
    config = BonsaiClientConfig()
    config.server = "http://127.0.0.1:9000"
    config.workspace = "500"
    config.access_key = "1111"
    sim = MinimalSim(config)
    return sim
Beispiel #6
0
def test_no_access_key_throws_error():
    config = BonsaiClientConfig()
    config.workspace = "1"
    try:
        BonsaiClient(config)
        assert False
    except RuntimeError:
        pass
Beispiel #7
0
def test_404_err_registration():
    config = BonsaiClientConfig()
    config.server = "http://127.0.0.1:9000"
    config.workspace = "notfound"
    config.access_key = "111"

    client = BonsaiClient(config)

    try:
        interface = SimulatorInterface(name="a", timeout=1)
        client.session.create(config.workspace, interface)
    except HttpResponseError as err:
        assert err.status_code == 404
Beispiel #8
0
def test_flaky_sim(patched_sleep: Mock):
    config = BonsaiClientConfig()
    config.server = "http://127.0.0.1:9000"
    config.workspace = "flaky"
    config.access_key = "111"

    client = BonsaiClient(config)

    interface = SimulatorInterface(name="a", timeout=1)
    client.session.create(config.workspace, interface)

    counter = 0
    while counter < 100:
        sim_state = SimulatorState(session_id=1,
                                   sequence_id=1,
                                   state={},
                                   halted=False)
        client.session.advance(config.workspace, 1, body=sim_state)
        counter += 1
Beispiel #9
0
def test_default_client_construction():
    config = BonsaiClientConfig()
    config.access_key = "1"
    config.workspace = "2"
    BonsaiClient(config)