def test_exists(self):
        client = mock.Mock()
        client.exists.return_value = True

        store = RedisBackingStore(60, client)

        self.assertTrue(store.exists("get_templates"))
        client.exists.assert_called_once_with("get_templates")
    def test_retrieve(self):
        client = mock.Mock()
        client.get.return_value = "\x80\x02K\nU\rget_templatesq\x01\x86q\x02."

        store = RedisBackingStore(60, client)
        result = store.retrieve("get_templates")
        self.assertEqual((10, "get_templates"), result)
        client.get.assert_called_once_with("get_templates")
 def test_cache_exc_handling(self):
     mock_client = mock.Mock()
     mock_client.set.side_effect = Exception("message")
     store = RedisBackingStore(60, mock_client)
     store.cache("get_templates", "content")
    def test_cache(self):
        mock_client = mock.Mock()
        store = RedisBackingStore(60, mock_client)
        store.cache("get_templates", "content")

        mock_client.set.assert_called_once_with("get_templates", "\x80\x02U\x07contentq\x01.")
    def test_retrieve_generic_exc_handling(self):
        client = mock.Mock()
        client.get.side_effect = Exception()

        store = RedisBackingStore(60, client)
        self.assertEqual(None, store.retrieve("get_templates"))
    def test_retrieve_conn_exc_handling(self):
        client = mock.Mock()
        client.get.side_effect = ConnectionError()

        store = RedisBackingStore(60, client)
        self.assertEqual(None, store.retrieve("get_templates"))