MCPcopy
hub / github.com/redis/redis-py / test_restore

Method test_restore

tests/test_commands.py:8153–8175  ·  view source on GitHub ↗
(self, r)

Source from the content-addressed store, hash-verified

8151
8152 @skip_if_server_version_lt("2.6.0")
8153 def test_restore(self, r):
8154 # standard restore
8155 key = "foo"
8156 r.set(key, "bar")
8157 dumpdata = r.dump(key)
8158 r.delete(key)
8159 assert r.restore(key, 0, dumpdata)
8160 assert r.get(key) == b"bar"
8161
8162 # overwrite restore
8163 with pytest.raises(redis.exceptions.ResponseError):
8164 assert r.restore(key, 0, dumpdata)
8165 r.set(key, "a new value!")
8166 assert r.restore(key, 0, dumpdata, replace=True)
8167 assert r.get(key) == b"bar"
8168
8169 # ttl check
8170 key2 = "another"
8171 r.set(key2, "blee!")
8172 dumpdata = r.dump(key2)
8173 r.delete(key2)
8174 assert r.restore(key2, 0, dumpdata)
8175 assert r.ttl(key2) == -1
8176
8177 @skip_if_server_version_lt("5.0.0")
8178 def test_restore_idletime(self, r):

Callers

nothing calls this directly

Calls 6

dumpMethod · 0.80
restoreMethod · 0.80
setMethod · 0.45
deleteMethod · 0.45
getMethod · 0.45
ttlMethod · 0.45

Tested by

no test coverage detected