def test_factory_pattern(app, config): rq = RQ(default_timeout=123) rq.init_app(app) rq.default_timeout = 456 # override default timeout rq.job(add) add.helper.timeout == 456 add.helper.timeout = 789 add.helper.timeout == 789
def test_factory_pattern(app, config): rq = RQ(default_timeout=111) rq.init_app(app) # override some rq defaults rq.default_timeout = 222 rq.default_result_ttl = 333 rq.default_queue = 'non-default' rq.job(add) # then check if those default have been passed to the helper assert add.helper.timeout == 222 assert add.helper.result_ttl == 333 assert add.helper.queue_name == 'non-default' # then queue if the values have been passed to the job as well job = add.queue(1, 2) assert job.timeout == 222 assert job.result_ttl == 333 assert job.ttl is None assert job.origin == 'non-default' # change the values in the helpr and see if that works add.helper.timeout = 444 assert add.helper.timeout == 444 add.helper.result_ttl = 555 assert add.helper.result_ttl == 555 add.helper.queue_name = 'totally-different' assert add.helper.queue_name == 'totally-different' # assert the helper's values job = add.queue(1, 2) assert job.timeout == 444 assert job.result_ttl == 555 assert job.ttl is None assert job.origin == 'totally-different' # now finally override the values while queueing job = add.queue(1, 2, queue='yet-another', timeout=666, result_ttl=777, ttl=888) assert job.timeout == 666 assert job.result_ttl == 777 assert job.ttl == 888 assert job.origin == 'yet-another'
# define login_manager global for other modules login_manager = LoginManager() login_manager.login_view = 'login' # Initialize ESI connection, all three below globals are needed to set up ESI connection esiapp = App.create(config.ESI_SWAGGER_JSON) # init the security object esisecurity = EsiSecurity( app=esiapp, redirect_uri=config.ESI_CALLBACK, client_id=config.ESI_CLIENT_ID, secret_key=config.ESI_SECRET_KEY, headers={'User-Agent': config.ESI_USER_AGENT} ) # init the client esiclient = EsiClient( security=esisecurity, cache=None, headers={'User-Agent': config.ESI_USER_AGENT} ) # init RQ, result_ttl needs to be unset so that scheduled jobs will always continue to run rq = RQ() rq.default_result_ttl = None rq.default_timeout = config.DEFAULT_TIMEOUT # direct access to redis is needed for some components, like statistics caching r = redis.StrictRedis(host=config.REDIS_URL, port=config.REDIS_PORT, db=0)