End-to-end registry tests
This commit is contained in:
parent
dd28a845db
commit
9585e2a765
5 changed files with 262 additions and 8 deletions
|
@ -1,27 +1,31 @@
|
|||
from storage.basestorage import BaseStorage
|
||||
|
||||
_FAKE_STORAGE_MAP = {}
|
||||
|
||||
class FakeStorage(BaseStorage):
|
||||
def _init_path(self, path=None, create=False):
|
||||
return path
|
||||
|
||||
def get_content(self, path):
|
||||
raise IOError('Fake files are fake!')
|
||||
if not path in _FAKE_STORAGE_MAP:
|
||||
raise IOError('Fake file %s not found' % path)
|
||||
|
||||
return _FAKE_STORAGE_MAP.get(path)
|
||||
|
||||
def put_content(self, path, content):
|
||||
return path
|
||||
_FAKE_STORAGE_MAP[path] = content
|
||||
|
||||
def stream_read(self, path):
|
||||
yield ''
|
||||
yield _FAKE_STORAGE_MAP[path]
|
||||
|
||||
def stream_write(self, path, fp, content_type=None, content_encoding=None):
|
||||
pass
|
||||
_FAKE_STORAGE_MAP[path] = fp.read()
|
||||
|
||||
def remove(self, path):
|
||||
pass
|
||||
_FAKE_STORAGE_MAP.pop(path, None)
|
||||
|
||||
def exists(self, path):
|
||||
return False
|
||||
return path in _FAKE_STORAGE_MAP
|
||||
|
||||
def get_checksum(self, path):
|
||||
return 'abcdefg'
|
||||
return path
|
||||
|
|
Reference in a new issue