def test_add_buffer(app_client, watcher): packet = str.encode(dump_event(return_value(), 1)) app_client.protocol.add_buffer(packet) assert watcher.wait('return_value_success') assert watcher.wait('write') value = Value() value.value = 'Hello server!' value.errors = False value.node_call_id = 1 assert app_client.write_data == str.encode(dump_value(value) + '~~~')
def test_values(): event = Event() event.test_meta = 1 value = Value(event=event) value.value = 'foo' value.errors = False value.node_call_id = 1 x, id, errors, meta = load_value(dump_value(value)) assert value.value == x assert id == 1 assert not errors assert meta['test_meta'] == event.test_meta
def test_send(app_client, watcher): event = return_value() generator = app_client.protocol.send(event) next(generator) # exec assert watcher.wait('write') assert app_client.write_data == str.encode(dump_event(event, 0) + '~~~') value = Value() value.value = 'Hello server!' value.errors = False value.node_call_id = 0 app_client.protocol.add_buffer(str.encode(dump_value(value) + '~~~')) assert next(generator).getValue() == value.value