コード例 #1
0
def db_failing_manager():
    class FailingDatabase(Database):
        def store_call(self, call):
            raise DatabaseError('boom!')

    database = FailingDatabase()
    queue_service = QueueService()
    return WorkflowManager(database, queue_service)
コード例 #2
0
def test_get_call(unbounded_service):
    service = QueueService()
    call = 'call 1'
    call2 = 'call 2'

    service.put(call)
    service.put(call2)

    assert service.get() == call
    assert service.get() == call2
コード例 #3
0
def test_limited_queue():
    limited_service = QueueService(max_calls=1)
    call = 'a call'

    limited_service.put(call)

    with pytest.raises(QueueFullError):
        limited_service.put(call)
コード例 #4
0
def unbounded_service():
    return QueueService()
コード例 #5
0
def full_service():
    service = QueueService(max_calls=1)
    service.put('something')

    return service
コード例 #6
0
def queue_full_manager(database):
    full_queue = QueueService(max_calls=1)
    full_queue.put('cid')
    return WorkflowManager(database, full_queue)
コード例 #7
0
def workflow_manager(database):
    queue_service = QueueService()
    return WorkflowManager(database, queue_service)
コード例 #8
0
from flask import Flask, jsonify, request, logging

from callqueue.domain import parse_call
from callqueue.handler import WorkflowManager
from callqueue.database import InMemoryDatabase
from callqueue.queueservice import QueueService

app = Flask(__name__)
manager = WorkflowManager(InMemoryDatabase(),
                          QueueService(),
                          logger=logging.create_logger(app))


@app.route('/')
def index():
    return 'Hello World!'


@app.route('/queue', methods=['POST'])
def queue_call():
    body = request.json
    caller = parse_call(body)
    response = manager.greet_caller(caller)
    return jsonify(response)