def redis_restore(tempfile): with open(tempfile, 'r') as f: redisdl.load( f, host=config.REDIS_HOST, password=config.REDIS_PASSWORD )
def redis_restore(redis_creds, tempfile): with open(tempfile, 'r') as f: redisdl.load( f, host=redis_creds['host'], password=redis_creds['password'], )
def test_load_bytesio_yajl2_backend_str(self): self.assertTrue(redisdl.have_streaming_load) dump = '{"key":{"type":"string","value":"hello, world"}}' io = StringIO(dump) redisdl.load(io) value = self.r.get('key') self.assertEqual('hello, world', value.decode('ascii'))
def test_load_bytesio(self): self.assertTrue(redisdl.have_streaming_load) dump = '{"key":{"type":"string","value":"hello, world"}}' io = BytesIO(dump.encode('utf-8')) redisdl.load(io) value = self.r.get('key') self.assertEqual('hello, world', value.decode('ascii'))
def test_load_stringio_python_backend_local(self): self.assertTrue(redisdl.have_streaming_load) dump = '{"key":{"type":"string","value":"hello, world"}}' io = StringIO(dump) redisdl.load(io, streaming_backend='python') value = self.r.get('key') self.assertEqual('hello, world', value.decode('ascii'))
def test_load_bytesio_yajl2_backend_str(self): self.assertTrue(redisdl.have_streaming_load) dump = '{"key":{"type":"string","value":"hello, world"}}' io = StringIO(dump) redisdl.load(io) value = self.r.get("key") self.assertEqual("hello, world", value.decode("ascii"))
def test_load_stringio_python_backend_global(self): self.assertTrue(redisdl.have_streaming_load) redisdl.streaming_backend = "python" dump = '{"key":{"type":"string","value":"hello, world"}}' io = StringIO(dump) redisdl.load(io) value = self.r.get("key") self.assertEqual("hello, world", value.decode("ascii"))
def test_load_stringio_no_backend(self): if have_streaming_load: self.assertTrue(redisdl.have_streaming_load) redisdl.streaming_backend = None dump = '{"key":{"type":"string","value":"hello, world"}}' io = StringIO(unicode(dump)) redisdl.load(io) value = self.r.get('key') self.assertEqual('hello, world', value.decode('ascii'))
def do_load(options, args): if len(args) > 0: input = open(args[0], 'rb') else: input = sys.stdin kwargs = options_to_kwargs(options) load(input, **kwargs) if len(args) > 0: input.close()
def test_load_stringio_bytes(self): dump = '{"key":{"type":"string","value":"hello, world"}}' io = BytesIO(dump.encode('ascii')) redisdl.load(io) value = self.r.get('key') self.assertEqual('hello, world', value.decode('ascii'))
def restore(self): with open('%scategories/dump%s.json' % (persistence_path(), self.db), "r+") as f: redisdl.load(f, db=self.db, host=self.host, port=self.port)
def test_load_stringio_bytes(self): dump = '{"key":{"type":"string","value":"hello, world"}}' io = BytesIO(dump.encode("ascii")) redisdl.load(io) value = self.r.get("key") self.assertEqual("hello, world", value.decode("ascii"))
# requires pip install redis-dump-load import redisdl with open('redis-dump.json') as f: redisdl.load(f)