This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/storage/fakestorage.py
2015-06-01 16:35:30 -04:00

31 lines
771 B
Python

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):
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):
_FAKE_STORAGE_MAP[path] = content
def stream_read(self, path):
yield _FAKE_STORAGE_MAP[path]
def stream_write(self, path, fp, content_type=None, content_encoding=None):
_FAKE_STORAGE_MAP[path] = fp.read()
def remove(self, path):
_FAKE_STORAGE_MAP.pop(path, None)
def exists(self, path):
return path in _FAKE_STORAGE_MAP
def get_checksum(self, path):
return path