OLD | NEW |
(Empty) | |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 from future import Future |
| 6 from object_store import ObjectStore |
| 7 |
| 8 class TestObjectStore(ObjectStore): |
| 9 '''An object store which records its namespace and behaves like a dict, for |
| 10 testing. |
| 11 ''' |
| 12 def __init__(self, namespace): |
| 13 self.namespace = namespace |
| 14 self._store = {} |
| 15 |
| 16 def SetMulti(self, mapping, **optarg): |
| 17 self._store.update(mapping) |
| 18 |
| 19 def GetMulti(self, keys, **optargs): |
| 20 return Future(value=dict((k, v) for k, v in self._store.items() |
| 21 if k in keys)) |
| 22 |
| 23 def Delete(self, key): |
| 24 del self._store[key] |
OLD | NEW |