def then_i_receive_a_message_on_the_queue_with_data(step, expected_message, queue):
    events = bus_helper.get_messages_from_bus(queue)
    local_xivo_uuid = xivo_helper.get_uuid()

    for expected_event in step.hashes:
        raw_expected_event = {'name': expected_message,
                              'data': {}}

        if 'status' in expected_event:
            raw_expected_event['data']['status'] = expected_event['status']
        if 'to' in expected_event:
            raw_expected_event['data']['to'] = json.loads(expected_event['to'])
        if 'alias' in expected_event:
            raw_expected_event['data']['alias'] = expected_event['alias']
        if 'msg' in expected_event:
            raw_expected_event['data']['msg'] = expected_event['msg']

        if expected_event.get('origin_uuid', 'no') == 'yes':
            raw_expected_event['origin_uuid'] = local_xivo_uuid

        if expected_event.get('user_id', 'no') == 'yes':
            user = user_helper.get_by_firstname_lastname(expected_event['firstname'],
                                                         expected_event['lastname'])
            raw_expected_event['data']['user_id'] = user['id']

        if expected_event.get('user_uuid', 'no') == 'yes':
            user = user_helper.get_by_firstname_lastname(expected_event['firstname'],
                                                         expected_event['lastname'])
            raw_expected_event['data']['user_uuid'] = user['uuid']

        if expected_event.get('id', 'no') == 'ANY':
            raw_expected_event['data']['id'] = ANY

        if expected_event.get('uuid', 'no') == 'ANY':
            raw_expected_event['data']['uuid'] = ANY

        if expected_event.get('endpoint_id', 'no') == 'yes':
            line = line_read_helper.get_with_exten_context(expected_event['number'],
                                                           expected_event['context'])
            raw_expected_event['data']['endpoint_id'] = line['id']
            raw_expected_event['data']['status'] = int(expected_event['status'])

        if expected_event.get('agent_id', 'no') == 'yes':
            agent_id = agent_helper.find_agent_id_with_number(expected_event['agent_number'])
            raw_expected_event['data']['agent_id'] = agent_id

        if expected_event.get('from', 'no') == 'yes':
            user = user_helper.get_by_firstname_lastname(expected_event['firstname'],
                                                         expected_event['lastname'])
            from_ = [local_xivo_uuid, user['uuid']]
            raw_expected_event['data']['from'] = from_

        if expected_event.get('call_id') == 'ANY':
            raw_expected_event['data']['call_id'] = ANY

        assert_that(events, has_item(has_entries(raw_expected_event)))
def when_i_publish_a_chat_message(step):
    data = step.hashes[0]
    local_xivo_uuid = xivo_helper.get_uuid()
    user_uuid = user_helper.get_by_firstname_lastname(data['firstname'], data['lastname'])['uuid']
    to = local_xivo_uuid, user_uuid
    event = ChatMessageEvent(json.loads(data['from']), to, data['alias'], data['msg'])
    msg = Marshaler(local_xivo_uuid).marshal_message(event)
    _send_bus_msg(msg, event.routing_key)
Example #3
0
def log_user_in_client(firstname, lastname):
    user = user_helper.get_by_firstname_lastname(firstname, lastname)
    conf_dict = {
        'main_server_address': common.get_host_address(),
        'main_server_port': 5003,
        'login': user['username'],
        'password': user['password'],
        'agent_option': 'no',
    }
    configure_client(conf_dict)
    return log_in_the_xivo_client()
Example #4
0
def log_user_in_client(firstname, lastname):
    user = user_helper.get_by_firstname_lastname(firstname, lastname)
    conf_dict = {
        'main_server_address': common.get_host_address(),
        'main_server_port': 5003,
        'login': user.username,
        'password': user.password,
        'agent_option': 'no',
    }
    configure_client(conf_dict)
    return log_in_the_xivo_client()
def then_i_should_receive_the_following_chat_message(step):
    data = step.hashes[0]
    local_xivo_uuid = xivo_helper.get_uuid()
    user_uuid = user_helper.get_by_firstname_lastname(data['firstname'], data['lastname'])['uuid']
    to = local_xivo_uuid, user_uuid
    expected_raw_event = {'class': 'chitchat',
                          'alias': data['alias'],
                          'to': to,
                          'from': json.loads(data['from']),
                          'text': data['msg']}
    events = step.scenario._pseudo_xivo_client.events
    assert_that(_has_received_event_before_timeout(events, json.dumps(expected_raw_event), 5),
                'CTI event {} was not received'.format(expected_raw_event))
Example #6
0
def when_i_update_user_group1_group2_with_the_following_parameters(step, firstname, lastname):
    user = user_helper.get_by_firstname_lastname(firstname, lastname)
    userinfo = _get_user_info(step.hashes)
    world.response = user_action_confd.update_user(user['id'], userinfo)
def when_i_request_the_funckey_with_a_destination_for_user_group1_group2(step, firstname, lastname):
    user = user_helper.get_by_firstname_lastname(firstname, lastname)
    func_key_ids = func_key_helper.find_func_keys_with_user_destination(user.id)
    assert_that(func_key_ids, has_length(1), "More than one func key with the same destination")

    world.response = func_key_action_confd.get_func_key(func_key_ids[0])
def then_i_get_a_func_key_with_a_destination_id_for_user_group1_group2(step, firstname, lastname):
    destination_id = world.response.data['destination_id']
    user = user_helper.get_by_firstname_lastname(firstname, lastname)
    assert_that(user.id, equal_to(destination_id))
def _find_user_uuid(info):
    return user_helper.get_by_firstname_lastname(info['firstname'], info['lastname'])['uuid']
Example #10
0
def when_i_request_the_funckey_with_a_destination_for_user_group1_group2(step, firstname, lastname):
    user = user_helper.get_by_firstname_lastname(firstname, lastname)
    func_key_ids = func_key_helper.find_func_keys_with_user_destination(user.id)
    assert_that(func_key_ids, has_length(1), "More than one func key with the same destination")

    world.response = func_key_action_restapi.get_func_key(func_key_ids[0])
Example #11
0
def then_i_get_a_func_key_with_a_destination_id_for_user_group1_group2(step, firstname, lastname):
    destination_id = world.response.data['destination_id']
    user = user_helper.get_by_firstname_lastname(firstname, lastname)
    assert_that(user.id, equal_to(destination_id))