aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonan Amicel <ronan.amicel@gmail.com>2012-10-13 18:32:00 +0200
committerRonan Amicel <ronan.amicel@gmail.com>2012-10-13 18:58:21 +0200
commitddb26f014ad0eb0c947f9e3c0a441c55575edac5 (patch)
tree71b0fccd3879890f50fef480c26ee8af31f958b3
parentOnly change owner or permissions when needed (diff)
downloadfabtools-ddb26f014ad0eb0c947f9e3c0a441c55575edac5.tar.xz
Add test task for directory creation
-rw-r--r--fabtools/tests/fabfiles/files.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/fabtools/tests/fabfiles/files.py b/fabtools/tests/fabfiles/files.py
index 53fe462..f8f2b63 100644
--- a/fabtools/tests/fabfiles/files.py
+++ b/fabtools/tests/fabfiles/files.py
@@ -59,3 +59,36 @@ def files():
with fabtools.files.watch('watched', callback=partial(require.file, 'modified2')):
pass
assert not fabtools.files.is_file('modified2')
+
+
+@task
+def directories():
+ """
+ Check directory creation and modification
+ """
+
+ with cd('/tmp'):
+
+ sudo('rm -rf dir1 dir2')
+
+ # Test directory creation
+
+ require.directory('dir1')
+ assert fabtools.files.is_dir('dir1')
+ assert fabtools.files.owner('dir1') == env.user
+
+ # Test initial owner requirement
+
+ require.user('dirtest')
+ require.directory('dir2', owner='dirtest', use_sudo=True)
+
+ assert fabtools.files.is_dir('dir2')
+ assert fabtools.files.owner('dir2') == 'dirtest'
+
+ # Test changed owner requirement
+
+ require.user('dirtest2')
+ require.directory('dir2', owner='dirtest2', use_sudo=True)
+
+ assert fabtools.files.is_dir('dir2')
+ assert fabtools.files.owner('dir2') == 'dirtest2'