Пример #1
0
def test_handle_member_answer(database):
    event = create_event()
    add_members(event)

    nexmo_client = mock.create_autospec(nexmo.Client)

    ncco = voice.handle_member_answer(
        event_number="5678",
        member_number="202",
        origin_conversation_uuid="conversation",
        origin_call_uuid="call",
        client=nexmo_client,
    )

    assert len(ncco) == 2

    # The member should have been greeted and then connected to a conference
    # call.
    assert ncco[0]["action"] == "talk"
    assert "Test event" in ncco[0]["text"]
    assert "Alice" in ncco[0]["text"]
    assert ncco[1]["action"] == "conversation"
    assert ncco[1]["name"] == "conversation"

    # The conference call should have been notified that the member is joining.
    nexmo_client.send_speech.assert_called_once_with("call", text=mock.ANY)
Пример #2
0
def connect_to_conference(origin_conversation_uuid, origin_call_uuid, client):
    call = flask.request.get_json()
    member_number = lowlevel.normalize_e164_number(call["to"])
    event_number = lowlevel.normalize_e164_number(call["from"])

    ncco = voice.handle_member_answer(
        event_number=event_number,
        member_number=member_number,
        origin_conversation_uuid=origin_conversation_uuid,
        origin_call_uuid=origin_call_uuid,
    )

    return flask.jsonify(ncco)
Пример #3
0
def test_handle_member_answer_no_event(database):
    nexmo_client = mock.create_autospec(nexmo.Client)

    ncco = voice.handle_member_answer(
        event_number="5678",
        member_number="202",
        origin_conversation_uuid="conversation",
        origin_call_uuid="call",
        client=nexmo_client,
    )

    assert len(ncco) == 1
    assert ncco[0]["action"] == "talk"
    assert "error" in ncco[0]["text"]