aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tests/test_workbench.py
diff options
context:
space:
mode:
authorElrond <elrond+mediagoblin.org@samba-tng.org>2013-04-08 15:06:03 +0200
committerElrond <elrond+mediagoblin.org@samba-tng.org>2013-04-08 17:03:26 +0200
commit25067d811019bccb7b39bc7093a9b07a659c7a19 (patch)
tree4e0f2bf1b532b0bcf0daec94d05029fd970202d7 /mediagoblin/tests/test_workbench.py
parent8ec87dc3fddc70c000040e4983df923814de65cc (diff)
downloadmediagoblin-25067d811019bccb7b39bc7093a9b07a659c7a19.tar.lz
mediagoblin-25067d811019bccb7b39bc7093a9b07a659c7a19.tar.xz
mediagoblin-25067d811019bccb7b39bc7093a9b07a659c7a19.zip
Testing: Remove some left over files/dirs.
When using tempfile.* in testing, those files get created in the system tempdir. The docs say, we should try to remove them. Yes, the next reboot will clean them up also. And in the workbench case, check after each test, that the global workbench dir is empty (so the sub-workbcnhes have been destroyed).
Diffstat (limited to 'mediagoblin/tests/test_workbench.py')
-rw-r--r--mediagoblin/tests/test_workbench.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/mediagoblin/tests/test_workbench.py b/mediagoblin/tests/test_workbench.py
index 3b2fc2c6..9cd49671 100644
--- a/mediagoblin/tests/test_workbench.py
+++ b/mediagoblin/tests/test_workbench.py
@@ -26,8 +26,13 @@ from mediagoblin.tests.test_storage import get_tmp_filestorage
class TestWorkbench(object):
def setup(self):
+ self.workbench_base = tempfile.mkdtemp(prefix='gmg_workbench_testing')
self.workbench_manager = workbench.WorkbenchManager(
- os.path.join(tempfile.gettempdir(), u'mgoblin_workbench_testing'))
+ self.workbench_base)
+
+ def teardown(self):
+ # If the workbench is empty, this should work.
+ os.rmdir(self.workbench_base)
def test_create_workbench(self):
workbench = self.workbench_manager.create()
@@ -70,6 +75,7 @@ class TestWorkbench(object):
filename = this_workbench.localized_file(this_storage, filepath)
assert filename == os.path.join(
tmpdir, 'dir1/dir2/ourfile.txt')
+ this_storage.delete_file(filepath)
# with a fake remote file storage
tmpdir, this_storage = get_tmp_filestorage(fake_remote=True)
@@ -95,6 +101,9 @@ class TestWorkbench(object):
assert filename == os.path.join(
this_workbench.dir, 'thisfile.text')
+ this_storage.delete_file(filepath)
+ this_workbench.destroy()
+
def test_workbench_decorator(self):
"""Test @get_workbench decorator and automatic cleanup"""
# The decorator needs mg_globals.workbench_manager