def test_load_dumpfile(self):
     """Test loading a dumpfile"""
     here = os.path.split(os.path.abspath(__file__))[0]
     dumpfile = os.path.join(here, "./resources/dump.rdb")
     instance = RedisInstance(10101, dumpfile=dumpfile)
     self.assertEqual(instance.conn.get("foo"), "bar")
     instance.terminate()
    def test_start_stop(self):
        """Test starting and stopping an instance"""
        instance = RedisInstance(10101)
        self.assertIsNotNone(instance.conn.info())

        instance.terminate()
        self.assertRaises(redis.ConnectionError, lambda: instance.conn.info())
    def test_start_stop(self):
        """Test starting and stopping an instance"""
        instance = RedisInstance(10101)
        self.assertIsNotNone(instance.conn.info())

        instance.terminate()
        self.assertRaises(redis.ConnectionError, lambda: instance.conn.info())
 def test_load_dumpfile(self):
     """Test loading a dumpfile"""
     here = os.path.split(os.path.abspath(__file__))[0]
     dumpfile = os.path.join(here, './resources/dump.rdb')
     instance = RedisInstance(10101, dumpfile=dumpfile)
     self.assertEqual(instance.conn.get('foo'), 'bar')
     instance.terminate()
    def test_flush(self):
        """Test flushing the instance"""
        instance = RedisInstance(10101)

        instance.conn.set("foo", "bar")
        self.assertEqual(instance.conn.get("foo"), "bar")

        instance.flush()
        self.assertFalse(instance.conn.exists("foo"))

        instance.terminate()
    def test_flush(self):
        """Test flushing the instance"""
        instance = RedisInstance(10101)

        instance.conn.set('foo', 'bar')
        self.assertEqual(instance.conn.get('foo'), b'bar')

        instance.flush()
        self.assertFalse(instance.conn.exists('foo'))

        instance.terminate()
    def test_cleanup(self):
        """Test _cleanup kills all instance kinds"""
        redis = RedisInstance(10101)
        mongo = MongoInstance(10102)
        self.assertEqual(len(managed_instance.running_instances), 2)

        managed_instance._cleanup(exiting=True)
        self.assertEqual(len(managed_instance.running_instances), 0)
        self.assertFalse(os.path.exists(managed_instance.instance_tmpdir))

        # It's module-wide so reset this for future tests
        managed_instance.instance_tmpdir = tempfile.mkdtemp()
    def test_flush(self):
        """Test flushing the instance"""
        instance = RedisInstance(10101)

        instance.conn.set('foo', 'bar')
        self.assertEqual(instance.conn.get('foo'), 'bar')

        instance.flush()
        self.assertFalse(instance.conn.exists('foo'))

        instance.terminate()
 def test_gevent(self):
     """Test starting redis with gevent."""
     instance = RedisInstance(10101, use_gevent=True)
     self.assertEqual(len(managed_instance.running_instances), 1)
     instance.flush()
     instance.terminate()
 def test_get_logs(self):
     """Test getting the instance logs"""
     instance = RedisInstance(10101)
     logs = instance.get_logs()
     self.assertGreater(len(logs), 1000)
     instance.terminate()
 def test_gevent(self):
     """Test starting redis with gevent."""
     instance = RedisInstance(10101, use_gevent=True)
     self.assertEqual(len(managed_instance.running_instances), 1)
     instance.flush()
     instance.terminate()
 def test_get_logs(self):
     """Test getting the instance logs"""
     instance = RedisInstance(10101)
     logs = instance.get_logs()
     self.assertGreater(len(logs), 1000)
     instance.terminate()
 def test_failure(self, *args):
     """Test an instance that refuses to start"""
     self.assertRaises(ProcessNotStartingError,
                       lambda: RedisInstance(10101))