def test_get_app_property(app): coney = Coney(app) assert coney.app == app my_app = coney.get_app() assert my_app == app
def coney(app): with app.app_context(): coney = Coney(app) yield coney for consumer, thread in get_state(app).consumer_threads: consumer.stop() thread.join()
from flask import Flask from flask_coney import Coney app = Flask(__name__) app.config["CONEY_BROKER_URI"] = "amqp://*****:*****@rabbitmq" coney = Coney(app) @coney.queue(queue_name="process") def process_queue(ch, method, props, body): # do something with body print(body, flush=True)
def test_init_app(app): coney = Coney() coney.init_app(app) assert coney.app is None assert app.extensions["coney"] is not None
def test_get_app_missing(): coney = Coney() with pytest.raises(RuntimeError): coney.get_app()
def test_coney_broker_uri_not_set(): app = Flask(__name__) with pytest.raises(RuntimeError): Coney(app)