Ejemplo n.º 1
0
class TestRedisBackend(BackendTestBase, TestCase):
    def setUp(self):
        # Running Redis tests on the 5th db to avoid flushing existing
        # redis data on 0
        self.db = RedisBackend(host='localhost',
                               port=6379,
                               db=5,
                               id_generator=self.id_generator)
        super(TestRedisBackend, self).setUp()

    def tearDown(self):
        self.db.delete_db()

    def test_server_unreachable(self):
        with self.assertRaises(ConnectionError):
            RedisBackend(host='unreachable',
                         port=6379,
                         db=5,
                         id_generator=self.id_generator)

    @mock.patch('daybed.backends.redis.RedisBackend.__init__')
    def test_load_from_config(self, constructor_mock):
        constructor_mock.return_value = None
        config = mock.MagicMock()
        RedisBackend.load_from_config(config)
        self.assertTrue(constructor_mock.called)
Ejemplo n.º 2
0
class TestRedisBackend(BackendTestBase, TestCase):

    def setUp(self):
        # Running Redis tests on the 5th db to avoid flushing existing
        # redis data on 0
        self.db = RedisBackend(
            host='localhost',
            port=6379,
            db=5,
            id_generator=self.id_generator
        )
        super(TestRedisBackend, self).setUp()

    def tearDown(self):
        self.db.delete_db()

    def test_server_unreachable(self):
        with self.assertRaises(ConnectionError):
            RedisBackend(
                host='unreachable', port=6379, db=5,
                id_generator=self.id_generator
            )

    @mock.patch('daybed.backends.redis.RedisBackend.__init__')
    def test_load_from_config(self, constructor_mock):
        constructor_mock.return_value = None
        config = mock.MagicMock()
        RedisBackend.load_from_config(config)
        self.assertTrue(constructor_mock.called)
Ejemplo n.º 3
0
 def setUp(self):
     # Running Redis tests on the 5th db to avoid flushing existing
     # redis data on 0
     self.db = RedisBackend(host='localhost',
                            port=6379,
                            db=5,
                            id_generator=self.id_generator)
     super(TestRedisBackend, self).setUp()
Ejemplo n.º 4
0
 def setUp(self):
     # Running Redis tests on the 5th db to avoid flushing existing
     # redis data on 0
     self.db = RedisBackend(
         host='localhost',
         port=6379,
         db=5,
         id_generator=self.id_generator
     )
     super(TestRedisBackend, self).setUp()
Ejemplo n.º 5
0
 def setUp(self):
     # Running Redis tests on the 5th db to avoid flushing existing
     # redis data on 0
     self.db = RedisBackend(
         host='localhost',
         port=6379,
         db=5,
         id_generator=lambda: six.text_type(uuid4())
     )
     super(TestRedisBackend, self).setUp()
Ejemplo n.º 6
0
 def test_load_from_config(self, constructor_mock):
     constructor_mock.return_value = None
     config = mock.MagicMock()
     RedisBackend.load_from_config(config)
     self.assertTrue(constructor_mock.called)
Ejemplo n.º 7
0
 def test_server_unreachable(self):
     with self.assertRaises(ConnectionError):
         RedisBackend(host='unreachable',
                      port=6379,
                      db=5,
                      id_generator=self.id_generator)
Ejemplo n.º 8
0
 def test_load_from_config(self, constructor_mock):
     constructor_mock.return_value = None
     config = mock.MagicMock()
     RedisBackend.load_from_config(config)
     self.assertTrue(constructor_mock.called)