def test_empty_file_has_correct_permissions(): from fabtools.files import owner, group, mode from fabtools.require.files import file as require_file try: run_as_root('touch foo') require_file('bar', use_sudo=True) assert owner('foo') == owner('bar') assert group('foo') == group('bar') assert mode('foo') == mode('bar') finally: run_as_root('rm -f foo bar')
def test_permissions(): from fabtools.files import owner, group, mode from fabtools.require.files import directory as require_directory try: run_as_root('mkdir foo') require_directory('bar', use_sudo=True) assert owner('foo') == owner('bar') assert group('foo') == group('bar') assert mode('foo') == mode('bar') finally: run_as_root('rmdir foo bar')
def test_file_with_contents_has_correct_permissions(): from fabtools.files import owner, group, mode from fabtools.require.files import file as require_file try: run_as_root('echo "something" > foo') require_file('bar', contents='something', use_sudo=True) assert owner('foo') == owner('bar') assert group('foo') == group('bar') assert mode('foo') == mode('bar') finally: run_as_root('rm -f foo bar')