ashb commented on a change in pull request #4429: [AIRFLOW-3625] Add Redis 
Cluster support
URL: https://github.com/apache/airflow/pull/4429#discussion_r280355924
 
 

 ##########
 File path: tests/contrib/hooks/test_redis_cluster_hook.py
 ##########
 @@ -0,0 +1,74 @@
+# -*- coding: utf-8 -*-
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+import unittest
+from airflow import configuration
+from airflow.contrib.hooks.redis_cluster_hook import RedisClusterHook
+
+
+class TestRedisClusterHook(unittest.TestCase):
+
+    def setUp(self):
+        configuration.load_test_config()
+
+    def test_get_conn(self):
+        hook = RedisClusterHook(redis_cluster_conn_id='redis_cluster_default')
+        self.assertEqual(hook.client, None)
+        self.assertEqual(hook.skip_full_coverage_check, False)
+
+        self.assertEqual(
+            hook.startup_nodes,
+            [{'host': 'redis-cluster', 'port': 7000}],
+            'startup_nodes is correctly initialized.'
+        )
+        self.assertIs(hook.get_conn(), hook.get_conn(), 'Connection 
initialized only if None.')
+
+    def test_real_ping(self):
+        hook = RedisClusterHook(redis_cluster_conn_id='redis_cluster_default')
+        redis_cluster = hook.get_conn()
+
+        pong = redis_cluster.ping()
 
 Review comment:
   This feels like it is testing the behaviour of the redis cluster or the 
python bindings - we should assume they have their own tests.
   
   Instead I would suggest we mock StrictRedisCluster (we do this in other hook 
tests) and just check that we create the object right. This also means we don't 
need to run an _actual_ redis-cluster in our tests.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to