BVB Source Codes

rq Show test_helpers.py Source code

Return Download rq: download test_helpers.py Source code - Download rq Source code - Type:.py
  1. from rq.cli.helpers import get_redis_from_config
  2.  
  3. from tests import RQTestCase
  4.  
  5.  
  6. class TestHelpers(RQTestCase):
  7.  
  8.     def test_get_redis_from_config(self):
  9.         """Ensure Redis connection params are properly parsed"""
  10.         settings = {
  11.             'REDIS_URL': 'redis://localhost:1/1'
  12.         }
  13.  
  14.         # Ensure REDIS_URL is read
  15.         redis = get_redis_from_config(settings)
  16.         connection_kwargs = redis.connection_pool.connection_kwargs
  17.         self.assertEqual(connection_kwargs['db'], 1)
  18.         self.assertEqual(connection_kwargs['port'], 1)
  19.  
  20.         settings = {
  21.             'REDIS_URL': 'redis://localhost:1/1',
  22.             'REDIS_HOST': 'foo',
  23.             'REDIS_DB': 2,
  24.             'REDIS_PORT': 2,
  25.             'REDIS_PASSWORD': 'bar'
  26.         }
  27.  
  28.         # Ensure REDIS_URL is preferred
  29.         redis = get_redis_from_config(settings)
  30.         connection_kwargs = redis.connection_pool.connection_kwargs
  31.         self.assertEqual(connection_kwargs['db'], 1)
  32.         self.assertEqual(connection_kwargs['port'], 1)
  33.  
  34.         # Ensure fall back to regular connection parameters
  35.         settings['REDIS_URL'] = None
  36.         redis = get_redis_from_config(settings)
  37.         connection_kwargs = redis.connection_pool.connection_kwargs
  38.         self.assertEqual(connection_kwargs['host'], 'foo')
  39.         self.assertEqual(connection_kwargs['db'], 2)
  40.         self.assertEqual(connection_kwargs['port'], 2)
  41.         self.assertEqual(connection_kwargs['password'], 'bar')
  42.  
downloadtest_helpers.py Source code - Download rq Source code
Related Source Codes/Software:
amazon-dsstne - Deep Scalable Sparse Tensor Network Engine (DSSTNE... 2017-01-08
webpack-demos - a collection of simple demos of Webpack 2017-01-08
Squire - HTML5 rich text editor. Try the demo integration a... 2017-01-08
thor - Thor is a toolkit for building powerful command-li... 2017-01-08
glide - Package Management for Golang h... 2017-01-08
emmet-vim - emmet for vim: http://emmet.io/ ... 2017-01-08
prose - A Content Editor for GitHub. ht... 2017-01-08
sshrc - ring your .bashrc, .vimrc, etc. with you when you ... 2017-01-08
typed.js - A jQuery typing animation script. ... 2017-01-08
find - High-precision indoor positioning framework for mo... 2017-01-08
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top