def test_ensure_web_dir_rename(self): with mock.patch('os.path.exists', return_value=True), \ mock.patch('os.path.realpath', return_value='/home/c/ck/ckuehl/public_html'), \ mock.patch('subprocess.check_call') as check_call, \ freeze_time('2015-08-22 14:11:44'): ensure_web_dir('ckuehl') check_call.assert_has_calls([ mock.call([ 'sudo', 'install', '-d', '--mode=0755', '--group=ocf', '--owner=ckuehl', '--', '/services/http/users/c/ckuehl', ]), mock.call([ 'sudo', 'mv', '/home/c/ck/ckuehl/public_html', '/home/c/ck/ckuehl/public_html.08222015-141144' ]), mock.call([ 'sudo', '-u', 'ckuehl', 'ln', '-fs', '--', '/services/http/users/c/ckuehl', '/home/c/ck/ckuehl/public_html', ]), ])
def test_ensure_web_dir_existing(self): with mock.patch('os.path.exists', return_value=True), \ mock.patch('os.path.realpath', return_value='/services/http/users/c/ckuehl'), \ mock.patch('subprocess.check_call') as check_call: ensure_web_dir('ckuehl') check_call.assert_has_calls([ mock.call([ 'sudo', 'install', '-d', '--mode=0755', '--group=ocf', '--owner=ckuehl', '--', '/services/http/users/c/ckuehl', ]), mock.call([ 'sudo', '-u', 'ckuehl', 'ln', '-fs', '--', '/services/http/users/c/ckuehl', '/home/c/ck/ckuehl/public_html', ]), ])
def test_ensure_web_dir(self, check_call, _): ensure_web_dir('ckuehl') check_call.assert_has_calls([ mock.call([ 'sudo', 'install', '-d', '--mode=0755', '--group=ocf', '--owner=ckuehl', '--', '/services/http/users/c/ckuehl', ]), mock.call([ 'sudo', '-u', 'ckuehl', 'ln', '-fs', '--', '/services/http/users/c/ckuehl', '/home/c/ck/ckuehl/public_html', ]), ])