Add @get_workbench test
Test the decorator function and proper cleanup after it's usage. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
parent
bd6fe97746
commit
9408938bcc
@ -19,6 +19,8 @@ import tempfile
|
|||||||
|
|
||||||
|
|
||||||
from mediagoblin import workbench
|
from mediagoblin import workbench
|
||||||
|
from mediagoblin.mg_globals import setup_globals
|
||||||
|
from mediagoblin.decorators import get_workbench
|
||||||
from mediagoblin.tests.test_storage import get_tmp_filestorage
|
from mediagoblin.tests.test_storage import get_tmp_filestorage
|
||||||
|
|
||||||
|
|
||||||
@ -92,3 +94,18 @@ class TestWorkbench(object):
|
|||||||
this_storage, filepath, 'thisfile.text', False)
|
this_storage, filepath, 'thisfile.text', False)
|
||||||
assert filename == os.path.join(
|
assert filename == os.path.join(
|
||||||
this_workbench.dir, 'thisfile.text')
|
this_workbench.dir, 'thisfile.text')
|
||||||
|
|
||||||
|
def test_workbench_decorator(self):
|
||||||
|
"""Test @get_workbench decorator and automatic cleanup"""
|
||||||
|
# The decorator needs mg_globals.workbench_manager
|
||||||
|
setup_globals(workbench_manager=self.workbench_manager)
|
||||||
|
|
||||||
|
@get_workbench
|
||||||
|
def create_it(workbench=None):
|
||||||
|
# workbench dir exists?
|
||||||
|
assert os.path.isdir(workbench.dir)
|
||||||
|
return workbench.dir
|
||||||
|
|
||||||
|
benchdir = create_it()
|
||||||
|
# workbench dir has been cleaned up automatically?
|
||||||
|
assert not os.path.isdir(benchdir)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user