Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unarchive queue #54

Merged
merged 4 commits into from
Nov 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions features/archive/queue.feature

This file was deleted.

20 changes: 20 additions & 0 deletions features/daily/queue.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Feature: Queues

Scenario: Add a logged agent to a new queue and answer a call
Given there are telephony users with infos:
| firstname | lastname | exten | context | agent_number | protocol |
| John | Doe | 1102 | default | 1102 | sip |
When I log agent "1102" from phone
When I create the following queues:
| name | display_name | exten | context | agents |
| queue2 | Queue 2 | 3102 | default | 1102 |

Given there is an incall "3102@from-extern" to the queue "queue2"

When chan_test calls "3102@from-extern" with id "3102-1"
When I wait "1" seconds for the call processing
When "John Doe" answers
When I wait "1" seconds for the call processing
When "John Doe" hangs up
When chan_test hangs up channel with id "3102-1"
When I wait "1" seconds for the call processing
2 changes: 2 additions & 0 deletions wazo_acceptance/helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from .monit import Monit
from .pickup import Pickup
from .provd import Provd
from .queue import Queue
from .schedule import Schedule
from .sip_config import SIPConfigGenerator
from .sip_phone import LineRegistrar
Expand All @@ -44,6 +45,7 @@
'Monit',
'Pickup',
'Provd',
'Queue',
'Schedule',
'SIPConfigGenerator',
'Token',
Expand Down
40 changes: 40 additions & 0 deletions wazo_acceptance/helpers/queue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2019 The Wazo Authors (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later


class Queue:

def __init__(self, context):
self._context = context
self._confd_client = context.confd_client

def create(self, body):
with self._context.helpers.bus.wait_for_asterisk_reload(queue=True):
queue = self._confd_client.queues.create(body)
self._context.add_cleanup(self._confd_client.queues.delete, queue['id'])
return queue

def add_extension(self, queue, extension_id):
self._context.confd_client.queues(queue).add_extension(extension_id)
self._context.add_cleanup(
self._confd_client.queues(queue['id']).remove_extension,
extension_id
)

def add_agent_member(self, queue, agent_id):
self._context.confd_client.queues(queue['id']).add_agent_member(agent_id)
self._context.add_cleanup(
self._confd_client.queues(queue['id']).remove_agent_member,
agent_id
)

def get_by(self, **kwargs):
queue = self.find_by(**kwargs)
if not queue:
raise Exception('Queue not found: {}'.format(kwargs))
return queue

def find_by(self, **kwargs):
queues = self._confd_client.queues.list(**kwargs)['items']
for queue in queues:
return queue
3 changes: 2 additions & 1 deletion wazo_acceptance/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,9 @@ def setup_helpers(context):
context.helpers.monit = helpers.Monit(context)
context.helpers.pickup = helpers.Pickup(context)
context.helpers.provd = helpers.Provd(context)
context.helpers.token = helpers.Token(context)
context.helpers.queue = helpers.Queue(context)
context.helpers.schedule = helpers.Schedule(context)
context.helpers.token = helpers.Token(context)
context.helpers.user = helpers.User(context)
context.helpers.voicemail = helpers.Voicemail(context)

Expand Down
1 change: 1 addition & 0 deletions wazo_acceptance/steps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from .phone_call import * # noqa
from .presence import * # noqa
from .pickup import * # noqa
from .queue import * # noqa
from .process import * # noqa
from .provd import * # noqa
from .schedule import * # noqa
Expand Down
13 changes: 13 additions & 0 deletions wazo_acceptance/steps/incall.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,16 @@ def given_there_is_an_incall_to_the_ivr(context, exten, exten_context, ivr_name)
extension = context.helpers.extension.create(body)

context.helpers.incall.add_extension(incall, extension)


@given('there is an incall "{exten}@{exten_context}" to the queue "{queue_name}"')
def given_there_is_an_incall_to_the_queue(context, exten, exten_context, queue_name):
queue = context.helpers.queue.get_by(name=queue_name)

body = {'destination': {'type': 'queue', 'queue_id': queue['id']}}
incall = context.helpers.incall.create(body)

body = {'exten': exten, 'context': exten_context}
extension = context.helpers.extension.create(body)

context.helpers.incall.add_extension(incall, extension)
20 changes: 20 additions & 0 deletions wazo_acceptance/steps/phone_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ def step_user_is_talking(context, tracking_id):
phone = context.phone_register.get_phone(tracking_id)
until.true(phone.is_talking, tries=3)

@step('"{tracking_id}" answers')
def step_user_answers(context, tracking_id):
phone = context.phone_register.get_phone(tracking_id)
phone.answer()


@step('"{tracking_id}" hangs up')
def step_user_hangs_up(context, tracking_id):
phone = context.phone_register.get_phone(tracking_id)
phone.hangup()


@step('"{tracking_id}" calls "{exten}" and waits until the end')
def step_a_calls_exten_and_waits_until_the_end(context, tracking_id, exten):
Expand Down Expand Up @@ -88,5 +99,14 @@ def when_chan_test_queues_dtmf(context, digit, channel_id):
context.helpers.asterisk.send_to_asterisk_cli(cmd)


@when('chan_test hangs up channel with id "{channel_id}"')
def when_chan_test_hangs_up_channel_with_id(context, channel_id):
cmd = 'channel request hangup {prefix}/auto-{channel_id}'.format(
prefix=CHAN_PREFIX,
channel_id=channel_id,
)
context.helpers.asterisk.send_to_asterisk_cli(cmd)


def _sleep(seconds):
time.sleep(float(seconds))
39 changes: 39 additions & 0 deletions wazo_acceptance/steps/queue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2019 The Wazo Authors (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from behave import when


@when('I create the following queues')
def when_i_create_the_following_queues(context):
context.table.require_columns(['name', 'exten', 'context'])
for row in context.table:
body = {
'name': row['name'].lower(),
'label': row['display_name'],
'options': []
}
if 'maxlen' in row:
body['options'].append(['maxlen', row['maxlen']])
if 'joinempty' in row:
body['options'].append(['joinempty', row['joinempty']])
if 'leavewhenempty' in row:
body['options'].append(['leavewhenempty', row['leavewhenempty']])
if 'ringing_time' in row:
body['timeout'] = row['ringing_time']
if 'wrapuptime' in row:
body['options'].append(['wrapuptime', row['wrapuptime']])
if 'reachability_timeout' in row:
body['options'].append(['timeout', row['reachability_timeout']])
if 'ring_strategy' in row:
body['options'].append(['strategy', row['ring_strategy']])

queue = context.helpers.queue.create(body)

body = {'exten': row['exten'], 'context': row['context']}
extension = context.helpers.extension.create(body)
context.helpers.queue.add_extension(queue, extension['id'])

for agent_number in row.get('agents', '').split(','):
agent = context.helpers.agent.get_by(number=agent_number)
context.helpers.queue.add_agent_member(queue, agent['id'])