Fokko commented on a change in pull request #4090: [AIRFLOW-3250] Fix for Redis Hook for not authorised connection calls URL: https://github.com/apache/incubator-airflow/pull/4090#discussion_r234925879
########## File path: tests/contrib/sensors/test_redis_sensor.py ########## @@ -47,22 +47,25 @@ def setUp(self): key='test_key' ) - @patch("airflow.contrib.hooks.redis_hook.RedisHook.key_exists") - def test_poke(self, key_exists): - key_exists.return_value = True - self.assertTrue(self.sensor.poke(None)) + @patch("airflow.contrib.sensors.redis_key_sensor.RedisHook") + def test_poke(self, RedisHook): + RedisHook.return_value.get_conn.return_value.exists.side_effect = [True, False] + self.assertTrue(self.sensor.poke(None), "Key exists on first call.") + RedisHook.assert_called_once_with('redis_default') + RedisHook.return_value.get_conn.assert_called_once_with() + RedisHook.return_value.get_conn.return_value.exists.assert_called_once_with('test_key') + self.assertFalse(self.sensor.poke(None), "Key does NOT exists on second call.") - key_exists.return_value = False - self.assertFalse(self.sensor.poke(None)) - - @patch("airflow.contrib.hooks.redis_hook.StrictRedis.exists") - def test_existing_key_called(self, redis_client_exists): + @patch("airflow.contrib.hooks.redis_hook.StrictRedis") + @patch('airflow.contrib.hooks.redis_hook.RedisHook.get_connection') Review comment: We should not need to patches anymore, since we have Redis running. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services