From 11b2cf2bd5c49b9fd267d4b4ce4c13f07120397c Mon Sep 17 00:00:00 2001 From: Jacob Oscarson Date: Fri, 15 Mar 2013 15:23:54 +0100 Subject: [PATCH] Perform actual connection (+ increase test coverage) --- rq/scripts/__init__.py | 2 +- tests/test_scripts.py | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/rq/scripts/__init__.py b/rq/scripts/__init__.py index 43e195c..0e2ed97 100644 --- a/rq/scripts/__init__.py +++ b/rq/scripts/__init__.py @@ -56,5 +56,5 @@ def setup_redis(args): redis_conn = redis.StrictRedis.from_url(args.url, db=args.db) else: redis_conn = redis.StrictRedis(host=args.host, port=args.port, db=args.db, - password=args.password) + password=args.password, unix_socket_path=args.socket) use_connection(redis_conn) diff --git a/tests/test_scripts.py b/tests/test_scripts.py index 504cf96..3adce81 100644 --- a/tests/test_scripts.py +++ b/tests/test_scripts.py @@ -10,9 +10,12 @@ class uFaking(object): for attr in faking: setattr(self, attr, None) +def fake_args(): + return uFaking('host', 'port', 'url', 'socket', 'db', 'queues', 'password') + def conf_pair(**faked_settings): - return (faked_settings, - uFaking('host', 'port', 'socket', 'db', 'queues', 'password')) + return faked_settings, fake_args() + class TestScripts(TestCase): def test_config_file(self): @@ -40,3 +43,13 @@ class TestScripts(TestCase): add_standard_arguments(args) socket_parms = [e for e in caught if e[0] == '--socket'] self.assertEqual([('--socket', '-s')], socket_parms) + + def test_redis_socket_whiteboxish(self): + args = fake_args() + args.socket = '/no/such/path' + setup_redis(args) + + from rq import connections + conn = connections.pop_connection() + from redis.connection import UnixDomainSocketConnection + self.assertEqual(conn.connection_pool.connection_kwargs['path'], '/no/such/path')