From: Christopher Allan Webber Date: Sat, 11 Jun 2011 23:52:48 +0000 (-0500) Subject: Make sure workbench won't kill directories out of scope. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2ecee34f08ad367f54f7a066a2e3ce81aba01f0f;p=mediagoblin.git Make sure workbench won't kill directories out of scope. --- diff --git a/mediagoblin/tests/test_workbench.py b/mediagoblin/tests/test_workbench.py index 1d006645..83e90c3d 100644 --- a/mediagoblin/tests/test_workbench.py +++ b/mediagoblin/tests/test_workbench.py @@ -17,6 +17,8 @@ import os import tempfile +from nose.tools import assert_raises + from mediagoblin.process_media import workbench @@ -32,13 +34,21 @@ class TestWorkbench(object): def test_destroy_workbench(self): # kill a workbench - workbench = self.workbench_manager.create_workbench() - tmpfile = file(os.path.join(workbench, 'temp.txt'), 'w') + this_workbench = self.workbench_manager.create_workbench() + tmpfile = file(os.path.join(this_workbench, 'temp.txt'), 'w') with tmpfile: tmpfile.write('lollerskates') - assert os.path.exists(os.path.join(workbench, 'temp.txt')) + assert os.path.exists(os.path.join(this_workbench, 'temp.txt')) + + self.workbench_manager.destroy_workbench(this_workbench) + assert not os.path.exists(os.path.join(this_workbench, 'temp.txt')) + assert not os.path.exists(this_workbench) + + # make sure we can't kill other stuff though + dont_kill_this = tempfile.mkdtemp() - self.workbench_manager.destroy_workbench(workbench) - assert not os.path.exists(os.path.join(workbench, 'temp.txt')) - assert not os.path.exists(workbench) + assert_raises( + workbench.WorkbenchOutsideScope, + self.workbench_manager.destroy_workbench, + dont_kill_this)