Make the app config more powerful in terms of injecting fake dependencies. Refactor the tests to use metaclasses and to actually all run.
This commit is contained in:
parent
2a849f631b
commit
2cd98fc58e
15 changed files with 669 additions and 511 deletions
34
test/teststorage.py
Normal file
34
test/teststorage.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
from uuid import uuid4
|
||||
|
||||
from storage.basestorage import Storage
|
||||
|
||||
|
||||
class FakeStorage(Storage):
|
||||
def _init_path(self, path=None, create=False):
|
||||
return path
|
||||
|
||||
def get_content(self, path):
|
||||
raise IOError('Fake files are fake!')
|
||||
|
||||
def put_content(self, path, content):
|
||||
return path
|
||||
|
||||
def stream_read(self, path):
|
||||
yield ''
|
||||
|
||||
def stream_write(self, path, fp):
|
||||
pass
|
||||
|
||||
def exists(self, path):
|
||||
return True
|
||||
|
||||
|
||||
class FakeUserfiles(object):
|
||||
def prepare_for_drop(self, mime_type):
|
||||
return ('http://fake/url', uuid4())
|
||||
|
||||
def store_file(self, flask_file):
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_file_url(self, file_id, expires_in=300):
|
||||
return ('http://fake/url')
|
Reference in a new issue